Commit Graph

116 Commits

Author SHA1 Message Date
James Shubin
7331d3a7ee util: pprof: Improve pprof for ease of use
This makes it slightly cleaner.
2025-01-31 00:00:05 -05:00
James Shubin
d30ff6cfae legal: Remove year
Instead of constantly making these updates, let's just remove the year
since things are stored in git anyways, and this is not an actual modern
legal risk anymore.
2025-01-26 16:24:51 -05:00
James Shubin
1d3f2dbe3c util: Add a pprof helper package
As it turns out, there are other helper packages out there. I wrote this
before I realized that, and it didn't take me that long anyways.
2025-01-24 03:06:31 -05:00
James Shubin
c2f75d64a6 util: arch: The Any value should be the same everywhere
In 80e8c9cadc when this was ported, the
"Any" value diverged accidentally. This would cause some packages to not
be found, since they didn't match any arch.

Thanks to karpfen to digging into the issue.
2024-11-28 14:55:30 -05:00
James Shubin
b40d10a366 util: Add a generic map key and value swapping function
Fun little utility function which is useful.
2024-11-21 02:54:10 -05:00
James Shubin
3fb492f6aa util: Add a TLS helper
Make it easier to build TLS stuff in pure golang.
2024-11-01 19:41:35 -04:00
James Shubin
b140b2dfeb util: Move executable path finding into a helper function 2024-10-29 16:41:37 -04:00
James Shubin
8e3d959500 util: We prefer to append rather than truncate
This makes this utility function more useful.
2024-10-29 16:41:37 -04:00
James Shubin
8c886bbe7c util: Nil input to our simple cmd helper should be allowed
Don't panic here!
2024-10-29 16:41:37 -04:00
James Shubin
7d204dfb74 util: Add a simple append file write function
Similar to the golang os lib version except we append.
2024-10-29 16:39:46 -04:00
James Shubin
583f90dc7b util: distro: Rename functions to avoid golang stutter warning 2024-10-25 02:56:12 -04:00
James Shubin
2c967e3897 util: Add a simple template system for systemd unit files
Just the basics for what we need, nothing more. Not intended as a
general-purpose library for use elsewhere.
2024-10-24 17:29:00 -04:00
James Shubin
202a8e1fba util: Add a small helper to exec commands simply 2024-10-18 10:02:29 -04:00
James Shubin
e6085d77ff util: Add an flock utility for lock file type things
Useful for ensuring only one binary runs at the same time.
2024-10-18 10:02:29 -04:00
James Shubin
067eef9007 util: distro, engine: resources: Update virt-builder res
A little easier to maintain if we support more distros eventually.
2024-10-15 20:36:51 -04:00
James Shubin
e45d9be065 util: distro: Parse the os-release file 2024-10-15 20:36:51 -04:00
James Shubin
d24149518c util: distro: Refactor family and distro code
I hate writing abstraction code like this, but I'm hoping it will be
useful.
2024-10-15 20:36:50 -04:00
James Shubin
d403f18b2a util: distro: Put distro specific data in this util package
Try and see if we can put all our distro specific stuff in here...
2024-10-15 19:04:17 -04:00
James Shubin
b514022713 util: Add some path manipulation algorithms
These could use some optimization by an algorithmist! Not urgent right
now since they're not currently in any fast paths in the code.
2024-10-05 01:02:03 -04:00
James Shubin
74119a0a53 lang: core: strings, util: Add left and right padding functions
Golang didn't want these in the standard library, but they are useful.
2024-10-03 13:49:08 -04:00
James Shubin
13fc711657 util: Expanding home directory should preserve trailing slash
Because we consider slashes as a directory identifier when needed.
2024-09-26 12:29:43 -04:00
James Shubin
80e8c9cadc util: arch: Use small arch util library
Put all of the arch stuff that we can into this library.
2024-09-25 16:25:55 -04:00
James Shubin
06cc63fcb6 util: recwatch: Add a helper function for merging these
I should really rework the recwatch package and API, but I wasn't in the
mood to touch this code today, so this will have to do for now.
2024-09-13 19:48:00 -04:00
James Shubin
0a183dfff9 lang: funcs: txn, util: Fix typos 2024-07-25 12:44:58 -04:00
James Shubin
74f747e80b util: password: Fix suspicious dep issue
It seems that without warning, the author of this dep has nuked the old
version, and reorganized the source tree significantly. I'm not an
expert and cryptography routines, but this doesn't make me feel warm
inside. I hope more expert researchers could look into this so that we
avoid supply chain attacks.
2024-07-07 12:47:14 -04:00
James Shubin
6066cbf075 util: Add disjoint package to implement a union find datastructure
This is a fascinating, and incredibly simple data structure. I hope I
can end up using it for more than just type unification!

Thanks to Sam who taught me about its existence.
2024-07-01 14:05:48 -04:00
James Shubin
c12452b3ce misc: Move to golang 1.21
Unfortunately, this also breaks go-mod-upgrade with:

upgrade failed error=Error running go command to discover modules: exit
status 1 stderr=go: loading module retractions for
golang.org/x/mod@v0.16.0: version "v0.17.0" invalid: resolves to version
v0.17.1-0.20240315155916-aa51b25a4485 (v0.17.0 is not a tag) go: loading
module retractions for golang.org/x/sync@v0.6.0: version "v0.7.0"
invalid: resolves to version v0.7.1-0.20240304172602-14be23e5b48b
(v0.7.0 is not a tag)
2024-04-25 13:01:41 -04:00
James Shubin
964bd8ba61 util: Skip badly numbered versions
This let's us skip over pre-release versions like "40 Beta" or similar.
2024-03-30 13:54:09 -04:00
James Shubin
f75f6623b3 util: recwatch: Improve godoc 2024-03-22 02:56:59 -04:00
James Shubin
43b5a0ea6a util: recwatch: Remove last use of core logger
We've cleaned up quite a bit, yay!
2024-03-22 02:56:59 -04:00
James Shubin
b8a3c39984 util: password: Add a new helper util function for passwords
Also fix some doc issues from an earlier copy paste.
2024-03-22 00:55:03 -04:00
James Shubin
6347e275d3 util: Add a fedora mirror lookup function 2024-03-18 15:38:57 -04:00
James Shubin
4d18044851 util: Move recwatch package to util directory
This makes more sense and this is also a reminded that it needs a bit of
a cleanup.
2024-03-16 01:21:32 -04:00
James Shubin
6976f5f3f0 util: Add simple distro release version function
This helps us determine the latest version automatically as a user
convenience.
2024-03-08 17:57:13 -05:00
James Shubin
36ebddf986 util: Add a terrible heuristic for getting ethernet devices
I don't know of a better way. This will have to do for now.
2024-03-08 17:57:13 -05:00
James Shubin
b496f8d70a util: password: Add a helper to generate salted, hashed passwords
I have no idea if I'm doing this correctly, and I have no idea if the
library I am using is doing this correctly. Please check!
2024-03-08 17:57:13 -05:00
James Shubin
90f6d4e563 legal: Update http to https 2024-03-05 01:05:50 -05:00
James Shubin
3e31ee9455 legal: Additional permission under GNU GPL version 3 section 7
With the recent merging of embedded package imports and the entry CLI
package, it is now possible for users to build in mcl code into a single
binary. This additional permission makes it explicitly clear that this
is permitted to make it easier for those users. The condition is phrased
so that the terms can be "patched" by the original author if it's
necessary for the project. For example, if the name of the language
(mcl) changes, has a differently named new version, someone finds a
phrasing improvement or a legal loophole, or for some other
reasonable circumstance. Now go write some beautiful embedded tools!
2024-03-05 01:04:09 -05:00
James Shubin
f818f5ccf5 util: errwrap: Add more tests 2024-02-28 16:37:28 -05:00
James Shubin
dd0e67540f all: Remove deprecated io/ioutil package
Porting everything to the newer imports was trivial except for one
instance which required a very small refactor.
2024-02-28 16:36:49 -05:00
James Shubin
f60c25aacf util: Add afero relpath implementation
This new filesystem implements a relative filesystem modifier which can
be useful for converting between absolute filesystems rooted at / and
relative ones. This is particularly useful when interfacing with the
golang embed package.

The upstream requires a CLA, so we'll just store this here instead.
https://github.com/spf13/afero/pull/417
2024-02-22 17:41:13 -05:00
James Shubin
73ae197d20 util: Add scheme and path support to our fs util struct
This lets us have a custom URI when wrapping an Afero.Fs interface.
2024-02-22 13:46:27 -05:00
James Shubin
d887e7fea5 util: More error handling 2024-02-22 13:36:46 -05:00
James Shubin
871f0e73c0 lang, lib, util: Rename fs to be more unique
Trying to do a big refactor and this will help.
2024-02-22 13:36:46 -05:00
James Shubin
d117cb8ed5 util: Improve tree printing function
This makes it behave more like the core GNU tree util.
2024-02-22 13:36:46 -05:00
James Shubin
c78ef29bda util: safepath: Add AbsPath and RelPath
These add some new types for when you don't know if something is a file
or a directory, but you do know if it's absolute or relative.
2024-01-28 23:16:20 -05:00
James Shubin
a8f194259b legal: Happy 2024 everyone...
Done with:

ack '2023+' -l | xargs sed -i -e 's/2023+/2024+/g'

Checked manually with:

git add -p

Hello to future James from 2025, and Happy Hacking!
2024-01-22 15:52:49 -05:00
James Shubin
019b88cedf util: Add value to B64 serialization functions
These small utility functions are useful.
2023-12-03 16:52:01 -05:00
James Shubin
ab7eb0a293 util: password: Reverse the nonblocking stdin
It's not clear if this is absolutely necessary or not, but it probably
doesn't hurt. It's not clear if there is a way to read the previous
state before running this. Of course this isn't really thread-safe, so
use at your own risk.
2023-09-29 22:13:14 -04:00
James Shubin
01f249d484 util: password: Add a cancellable ReadPassword style functions
It was non-trivial to do this, so I put it into a library. Strangely I
couldn't directly wrap the ReadPassword function from the
golang.org/x/term package, as it wouldn't unblock for some reason.
2023-09-29 20:46:36 -04:00