Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
Loading items

Target

Select target project
  • oss/libraries/go/services/job-queues
1 result
Select Git revision
Loading items
Show changes
Showing
with 515 additions and 501 deletions
gopsutil is distributed under BSD license reproduced below.
Copyright (c) 2014, WAKAYAMA Shirou
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the gopsutil authors nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------
internal/common/binary.go in the gopsutil is copied and modified from golang/encoding/binary.go.
Copyright (c) 2009 The Go Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
BSD 3-Clause License
Copyright (c) 2018-2022, Tobias Klauser
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Copyright (c) 2017-2021 Uber Technologies, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Copyright (c) 2016-2017 Uber Technologies, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Copyright (c) 2009 The Go Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Copyright (c) 2009 The Go Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This project is covered by two different licenses: MIT and Apache.
#### MIT License ####
The following files were ported to Go from C files of libyaml, and thus
are still covered by their original MIT license, with the additional
copyright staring in 2011 when the project was ported over:
apic.go emitterc.go parserc.go readerc.go scannerc.go
writerc.go yamlh.go yamlprivateh.go
Copyright (c) 2006-2010 Kirill Simonov
Copyright (c) 2006-2011 Kirill Simonov
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
### Apache License ###
All the remaining project files are covered by the Apache license:
Copyright (c) 2011-2019 Canonical Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Copyright 2011-2016 Canonical Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
The MIT License (MIT)
Copyright (c) 2013-NOW Jinzhu <wosmvp@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
The MIT License (MIT)
Copyright (c) 2013-NOW Jinzhu <wosmvp@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
...@@ -101,7 +101,7 @@ func Trace(msg string, keysAndValues ...interface{}) { ...@@ -101,7 +101,7 @@ func Trace(msg string, keysAndValues ...interface{}) {
type ZapAdapter struct { type ZapAdapter struct {
logger *zap.Logger logger *zap.Logger
mu sync.Mutex // mu sync.Mutex
} }
func NewZapAdapter(logger *zap.Logger) *ZapAdapter { func NewZapAdapter(logger *zap.Logger) *ZapAdapter {
......
...@@ -137,6 +137,11 @@ func (m *Manager) GetActiveJobs() map[JobID]GenericJob { ...@@ -137,6 +137,11 @@ func (m *Manager) GetActiveJobs() map[JobID]GenericJob {
// DeleteJob removes a job from the active jobs and the database // DeleteJob removes a job from the active jobs and the database
func (m *Manager) DeleteJob(id JobID) error { func (m *Manager) DeleteJob(id JobID) error {
if m == nil {
return ErrManagerNotInitialized
}
m.mu.Lock() m.mu.Lock()
defer m.mu.Unlock() defer m.mu.Unlock()
...@@ -153,36 +158,54 @@ func (m *Manager) DeleteJob(id JobID) error { ...@@ -153,36 +158,54 @@ func (m *Manager) DeleteJob(id JobID) error {
} }
if m.jobSyncer != nil { if m.jobSyncer != nil {
err := m.jobSyncer.DeleteJob(job) return m.jobSyncer.DeleteJob(job)
if err != nil {
return err
}
} }
return nil return nil
} }
func (m *Manager) WaitSync() { func (m *Manager) WaitSync() error {
if m == nil {
return ErrManagerNotInitialized
}
m.mu.Lock() m.mu.Lock()
defer m.mu.Unlock() defer m.mu.Unlock()
if m.jobSyncer != nil { if m.jobSyncer != nil {
_ = m.jobSyncer.Wait(2 * time.Second) return m.jobSyncer.Wait(2 * time.Second)
} }
return nil
}
func (m *Manager) Sync(job GenericJob) error {
if m == nil {
return ErrManagerNotInitialized
} }
func (m *Manager) Sync(job GenericJob) {
m.mu.Lock() m.mu.Lock()
defer m.mu.Unlock() defer m.mu.Unlock()
if m.jobSyncer != nil { if m.jobSyncer != nil {
m.jobSyncer.Sync(job) return m.jobSyncer.Sync(job)
} }
return nil
} }
// RemoveJob removes a job from the active jobs // RemoveJob removes a job from the active jobs
// If you want to remove a job from the active jobs and the database, use DeleteJob instead // If you want to remove a job from the active jobs and the database, use DeleteJob instead
func (m *Manager) RemoveJob(id JobID) error { func (m *Manager) RemoveJob(id JobID) error {
if m == nil {
return ErrManagerNotInitialized
}
m.mu.Lock() m.mu.Lock()
defer m.mu.Unlock() defer m.mu.Unlock()
...@@ -195,6 +218,11 @@ func (m *Manager) RemoveJob(id JobID) error { ...@@ -195,6 +218,11 @@ func (m *Manager) RemoveJob(id JobID) error {
// ResetJobLogs deletes the logs of a job // ResetJobLogs deletes the logs of a job
func (m *Manager) ResetJobLogs(id JobID) error { func (m *Manager) ResetJobLogs(id JobID) error {
if m == nil {
return ErrManagerNotInitialized
}
m.mu.Lock() m.mu.Lock()
defer m.mu.Unlock() defer m.mu.Unlock()
...@@ -215,6 +243,11 @@ func (m *Manager) ResetJobLogs(id JobID) error { ...@@ -215,6 +243,11 @@ func (m *Manager) ResetJobLogs(id JobID) error {
// ResetJobStats deletes the stats of a job // ResetJobStats deletes the stats of a job
func (m *Manager) ResetJobStats(id JobID) error { func (m *Manager) ResetJobStats(id JobID) error {
if m == nil {
return ErrManagerNotInitialized
}
m.mu.Lock() m.mu.Lock()
defer m.mu.Unlock() defer m.mu.Unlock()
...@@ -250,6 +283,10 @@ func cancelSchedulerByManager(scheduler CancelScheduler, id JobID) error { ...@@ -250,6 +283,10 @@ func cancelSchedulerByManager(scheduler CancelScheduler, id JobID) error {
func (m *Manager) removeJobInternal(id JobID) error { func (m *Manager) removeJobInternal(id JobID) error {
if m == nil {
return ErrManagerNotInitialized
}
scheduler := m.activeJobs[id].GetScheduler() scheduler := m.activeJobs[id].GetScheduler()
if scheduler == nil { if scheduler == nil {
return ErrJobNotScheduled return ErrJobNotScheduled
...@@ -270,6 +307,11 @@ func (m *Manager) removeJobInternal(id JobID) error { ...@@ -270,6 +307,11 @@ func (m *Manager) removeJobInternal(id JobID) error {
} }
func (m *Manager) UpdateJob(job GenericJob) error { func (m *Manager) UpdateJob(job GenericJob) error {
if m == nil {
return ErrManagerNotInitialized
}
m.mu.Lock() m.mu.Lock()
defer m.mu.Unlock() defer m.mu.Unlock()
...@@ -318,6 +360,10 @@ func (m *Manager) GetDB() *gorm.DB { ...@@ -318,6 +360,10 @@ func (m *Manager) GetDB() *gorm.DB {
// GetQueue returns the queue // GetQueue returns the queue
func (m *Manager) checkAndSetRunningState() error { func (m *Manager) checkAndSetRunningState() error {
if m == nil {
return ErrManagerNotInitialized
}
m.state = ManagerStateStopped m.state = ManagerStateStopped
if m.workerMap == nil { if m.workerMap == nil {
...@@ -340,6 +386,11 @@ func (m *Manager) checkAndSetRunningState() error { ...@@ -340,6 +386,11 @@ func (m *Manager) checkAndSetRunningState() error {
// AddWorker adds a worker to the manager // AddWorker adds a worker to the manager
func (m *Manager) AddWorker(worker Worker) error { func (m *Manager) AddWorker(worker Worker) error {
if m == nil {
return ErrManagerNotInitialized
}
m.mu.Lock() m.mu.Lock()
defer m.mu.Unlock() defer m.mu.Unlock()
...@@ -369,6 +420,11 @@ func (m *Manager) AddWorker(worker Worker) error { ...@@ -369,6 +420,11 @@ func (m *Manager) AddWorker(worker Worker) error {
// RemoveWorker removes a worker from the manager // RemoveWorker removes a worker from the manager
func (m *Manager) RemoveWorker(worker Worker) error { func (m *Manager) RemoveWorker(worker Worker) error {
if m == nil {
return ErrManagerNotInitialized
}
m.mu.Lock() m.mu.Lock()
defer m.mu.Unlock() defer m.mu.Unlock()
...@@ -400,6 +456,10 @@ func (m *Manager) RemoveWorker(worker Worker) error { ...@@ -400,6 +456,10 @@ func (m *Manager) RemoveWorker(worker Worker) error {
// Start starts the manager // Start starts the manager
func (m *Manager) Start() error { func (m *Manager) Start() error {
if m == nil {
return ErrManagerNotInitialized
}
m.mu.Lock() m.mu.Lock()
defer m.mu.Unlock() defer m.mu.Unlock()
...@@ -407,7 +467,7 @@ func (m *Manager) Start() error { ...@@ -407,7 +467,7 @@ func (m *Manager) Start() error {
return ErrManagerAlreadyRunning return ErrManagerAlreadyRunning
} }
if m.jobSyncer == nil { if m.jobSyncer == nil && m.database != nil {
m.jobSyncer = NewJobSyncer(m) m.jobSyncer = NewJobSyncer(m)
} }
...@@ -575,7 +635,7 @@ func (m *Manager) ScheduleJob(job GenericJob, scheduler Scheduler) error { ...@@ -575,7 +635,7 @@ func (m *Manager) ScheduleJob(job GenericJob, scheduler Scheduler) error {
m.activeJobs[job.GetID()] = job m.activeJobs[job.GetID()] = job
if m.jobSyncer != nil { if m.jobSyncer != nil {
m.jobSyncer.Sync(job) return m.jobSyncer.Sync(job)
} }
return nil return nil
...@@ -656,7 +716,7 @@ func (m *Manager) handleJobEvents() { ...@@ -656,7 +716,7 @@ func (m *Manager) handleJobEvents() {
} }
} }
if assigned == true { if assigned {
break break
} }
......
{
pkgs,
lib,
...
}: let
common = pkgs.callPackage ./common.nix {};
# Definieren eines schreibbaren Verzeichnisses
writableDir = pkgs.stdenv.mkDerivation {
name = "cover-report";
buildCommand = ''
mkdir -p $out
'';
};
in
pkgs.writeShellScriptBin "build-cover-report" ''
${common}
echo_header "Building cover report"
download_test_images
setup_go_env
echo_section "Building"
${pkgs.go}/bin/go test -v -coverprofile=${writableDir}/coverage.out ./...
if [ $? -ne 0 ];
then
echo_fail "Failed to run tests"
exit 1
fi
if ! ${pkgs.go}/bin/go tool cover -html=${writableDir}/coverage.out -o ${writableDir}/coverage.html
then
echo_fail "Failed to generate coverage report"
exit 1
fi
echo_ok "Coverage report stored at ${writableDir}"
echo_step "Opening coverage report in browser"
if ! ${pkgs.xdg-utils}/bin/xdg-open ${writableDir}/coverage.html > /dev/null 2>&1
then
echo_fail "Failed to open coverage report in browser"
exit 1
fi
echo_ok "Report opened in browser"
''
{
pkgs,
lib,
...
}: let
common = pkgs.callPackage ./common.nix {};
in
pkgs.writeShellScriptBin "check-code" ''
${common}
echo_header "Checking code"
cd_working_dir
echo_step "Formatting Nix code"
if ! ${pkgs.alejandra}/bin/alejandra flake.nix ./nix/scripts/*.nix
then
echo_fail "alejandra formatting failed"
exit 1
fi
##format go code
echo_step "Formatting Go code"
if ! ${pkgs.go}/bin/gofmt -s -w .
then
echo_fail "gofmt failed"
exit 1
fi
echo_step "Add license headers"
if ! ${pkgs.addlicense}/bin/addlicense -c "schukai GmbH" -s -l "AGPL-3.0" ./*.go
then
echo_fail "addlicense failed"
exit 1
fi
echo_step "Running go test"
readonly defaultPacke=$(awk -F ' ' '/^module / { print $2 }' ./go.mod)
${pkgs.go-licenses}/bin/go-licenses save "$defaultPacke" --ignore "gitlab.schukai.com" --force --save_path ./licenses/
echo_step "Running go vet"
if ! ${pkgs.go}/bin/go vet .
then
echo_fail "go vet failed"
exit 1
fi
echo_step "Running go fmt"
if ! ${pkgs.go}/bin/go fmt .
then
echo_fail "go fmt failed"
exit 1
fi
echo_step "Running go mod tidy"
if ! ${pkgs.go}/bin/go mod tidy
then
echo_fail "go mod tidy failed"
exit 1
fi
echo_step "Running lint"
if ! ${pkgs.golangci-lint}/bin/golangci-lint run .
then
echo_fail "lint failed"
exit 1
fi
echo_step "Running gosec"
if ! ${pkgs.gosec}/bin/gosec -quiet .
then
echo_fail "gosec failed"
exit 1
fi
''
{
pkgs,
lib,
...
}: let
common = pkgs.callPackage ./common.nix {};
in
pkgs.writeShellScriptBin "clean-up" ''
${common}
echo_header "Cleaning up"
echo_step "Removing credentials"
${pkgs.git}/bin/git config --global --unset credential.helper
if [ -f /root/.docker/config.json ]; then rm /root/.docker/config.json; fi
echo_ok "Cleaned up"
''
{pkgs, ...}: ''
if [ -t 1 ]; then
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
RESET='\033[0m'
BOLD='\033[1m'
else
RED=""
GREEN=""
BLUE=""
RESET=""
fi
## this function is used to change the working directory to the one specified in
## the USER_WORKING_DIR environment variable. this is necessary if you want to edit
## files in the repository.
cd_working_dir() {
working_dir=$(echo $USER_WORKING_DIR)
if [ -z "$working_dir" ]; then
echo_fail "USER_WORKING_DIR is not set"
echo_hint "Please set the USER_WORKING_DIR environment variable"
exit 1
fi
if [ ! -d "$working_dir" ]; then
echo_fail "USER_WORKING_DIR does not exist"
echo_hint "Please set the USER_WORKING_DIR environment variable to a valid directory"
exit 1
fi
cd $working_dir
git_root=$(git rev-parse --show-toplevel)
if [ -z "$git_root" ]; then
echo_fail "Not a git repository"
echo_hint "Please run this script in a git repository"
exit 1
fi
cd $git_root
echo_ok "Changed directory to $working_dir"
}
is_true() {
val="$1"
if [ "$val" = 'true' ] || [ "$val" = '1' ]; then
return 0
else
return 1
fi
}
echo_header() {
${pkgs.figlet}/bin/figlet -t -f doom -l "$1"
}
echo_ok() {
echo -e "$GREEN✔$RESET $1"
}
echo_delimiter() {
echo " "
}
echo_section() {
echo -e "\n\n$BOLD$1$RESET"
}
echo_text() {
echo -e "$1"
}
echo_fail() {
echo -e "$RED✖ $1$RESET"
}
echo_hint() {
echo -e "$BLUE→ $1$RESET"
}
echo_step() {
echo -e "$BLUE•$RESET $1"
}
convert_multiline_for_nix() {
printf "%s" "
}$1" | ${pkgs.gnused}/bin/sed 's/\\/\\\\/g; s/"/\\"/g; s/$/\\n/g' | tr -d '\n'
}
if [ -z "$DEBUG_MODE" ]; then
DEBUG_MODE='false'
fi
if [ -n "$CI_JOB_TOKEN" ]; then
CI_MODE='true'
fi
if is_true "$DEBUG_MODE" || is_true "$CI_MODE"; then
set -x
fi
download_test_images() {
echo_step "Downloading docker images"
if ! ${pkgs.docker}/bin/docker images | grep atmoz/sftp | grep alpine
then
echo_step "Downloading atmoz/sftp:alpine"
if ! ${pkgs.docker}/bin/docker pull atmoz/sftp:alpine
then
echo_fail "Failed to download atmoz/sftp:alpine"
exit 1
fi
fi
if ! ${pkgs.docker}/bin/docker images | grep axllent/mailpit
then
echo_step "Downloading atmoz/sftp:alpine"
if ! ${pkgs.docker}/bin/docker pull axllent/mailpit
then
echo_fail "Failed to download axllent/mailpit"
exit 1
fi
fi
}
setup_go_env() {
echo_step "Changing directory to ${../..}"
cd ${../..}
echo_step "Setting GO111MODULE=auto"
if ! ${pkgs.go}/bin/go env -w GO111MODULE=auto
then
echo_fail "Failed to set GO111MODULE=auto"
exit 1
fi
}
''
{
pkgs,
lib,
...
}: let
common = pkgs.callPackage ./common.nix {};
in
pkgs.writeShellScriptBin "deploy" ''
${common}
echo_header "Deploying"
setup_go_env
if [ -z "''$CI_JOB_TOKEN" ]; then
echo_fail "Error: CI_JOB_TOKEN variable is not set."
exit 1
fi
if [ -z "''${CI_REPOSITORY_URL}" ]; then
echo_fail "Error: CI_REPOSITORY_URL environment variable is not set."
exit 1
fi
if [ -z "''${CI_PROJECT_DIR}" ]; then
echo_fail "Error: CI_PROJECT_DIR environment variable is not set."
exit 1
fi
cd ''${CI_PROJECT_DIR} || exit 1
${pkgs.git}/bin/git config --global user.email "''${GITLAB_USER_EMAIL}"
${pkgs.git}/bin/git config --global user.name "''${GITLAB_USER_NAME:-"Gitlab CI"}"
${pkgs.git}/bin/git config --global credential.helper '!f() { echo "username=gitlab-ci-token"; echo "password=''${CI_JOB_TOKEN}"; }; f'
${pkgs.git}/bin/git config --global pull.rebase true
${pkgs.git}/bin/git config --global http.sslVerify "false"
${pkgs.git}/bin/git remote set-url origin https://pad:''${GITLAB_TOKEN}@''${CI_REPOSITORY_URL#*@}
${pkgs.git}/bin/git fetch --all --tags --unshallow
${pkgs.git}/bin/git reset --hard origin/master
${pkgs.git}/bin/git clean -fd
${pkgs.git}/bin/git checkout $CI_COMMIT_REF_NAME
${pkgs.git}/bin/git pull origin $CI_COMMIT_REF_NAME
${pkgs.git}/bin/git --no-pager log --decorate=short --pretty=oneline
${pkgs.git}/bin/git fetch --prune --prune-tags
if ! ${pkgs.git}/bin/git --no-pager log --decorate=short --pretty=oneline
then
echo_fail "Error: Could not get git log."
exit 1
fi
echo_step "Bumping version"
gitVersion=v$(version predict)
${pkgs.git}/bin/git tag -a $gitVersion -m"chore: bump version"
${pkgs.git}/bin/git --no-pager log --decorate=short --pretty=oneline
${pkgs.git}/bin/git push -o ci.skip origin ''${CI_COMMIT_REF_NAME} --tags
echo_ok "done"
''
{pkgs}: let
taskfile = builtins.toFile "taskfile.yml" ''
version: '3'
tasks:
default:
cmds:
- task --list
silent: true
run-tests:
desc: Execute all tests.
aliases:
- rt
env:
TEST_BY_TASK: true
USER_WORKING_DIR: "{{.USER_WORKING_DIR}}"
cmds:
- run-tests
silent: true
run-extended-tests:
desc: Execute all tests including cover, bench and race tests.
aliases:
- ret
env:
TEST_BY_TASK: true
USER_WORKING_DIR: "{{.USER_WORKING_DIR}}"
cmds:
- run-extended-tests
silent: true
build-cover-report:
desc: Build coverage report.
aliases:
- cr
env:
TEST_BY_TASK: true
cmds:
- build-cover-report
silent: true
check-code:
desc: Check code style, linting, and formatting.
aliases:
- cc
env:
USER_WORKING_DIR: "{{.USER_WORKING_DIR}}"
cmds:
- check-code
silent: true
git-commit:
desc: Commit changes.
aliases:
- gc
- commit
cmds:
- check-code
- cd "{{.USER_WORKING_DIR}}" && cd $(git rev-parse --show-toplevel) && nix run git+https://gitlab.schukai.com/schukai/entwicklung/nix-flakes#git-commit --no-write-lock-file
silent: true
env:
USER_WORKING_DIR: "{{.USER_WORKING_DIR}}"
'';
in
pkgs.writeShellScriptBin "task" ''
${pkgs.go-task}/bin/task -t "${taskfile}" "$@"
''
{
pkgs,
lib,
...
}: let
common = pkgs.callPackage ./common.nix {};
in
pkgs.writeShellScriptBin "run-ci-tests" ''
${common}
echo_header "Running CI tests"
download_test_images
setup_go_env
echo_section "Running tests"
if ! ${pkgs.go}/bin/go test -tags "runOnTask" ./...
then
echo_fail "Failed to run tests"
exit 1
fi
''