Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keystore commands for ox #588

Merged
merged 11 commits into from
Aug 29, 2024
Merged

keystore commands for ox #588

merged 11 commits into from
Aug 29, 2024

Commits on Aug 26, 2024

  1. Add the PATCH /object/path/:ns/:kind/:name/keys api handler

    For cfg, sec and usr objects.
    
    Example:
    
    	$ curl -s -k -o- -u cva:xxx -X PATCH -H "Content-Type: application/json" --data '[{"key": "foo1", "bytes": "YmFyCg==", "action": "add"},{"key": "foo2", "string": "bar", "action": "add"}]' https://localhost:1215/object/path/test/cfg/hdoc/keys
    
    	$ om test/cfg/hdoc decode --key foo1
    	bar
    
    	$ om test/cfg/hdoc decode --key foo2
    	bar
    cvaroqui committed Aug 26, 2024
    Configuration menu
    Copy the full SHA
    c611de9 View commit details
    Browse the repository at this point in the history
  2. Add more object kvstore handlers

    GET    /object/path/:ns/:kind/:name/kvstore?key=k1&key=k2
    PATCH  /object/path/:ns/:kind/:name/kvstore
    GET    /object/path/:ns/:kind/:name/kvstore/entry?key=...
    POST   /object/path/:ns/:kind/:name/kvstore/entry?key=...
    DELETE /object/path/:ns/:kind/:name/kvstore/entry?key=...
    cvaroqui committed Aug 26, 2024
    Configuration menu
    Copy the full SHA
    b5e6030 View commit details
    Browse the repository at this point in the history
  3. Add one more kvstore handler

    GET /object/path/:ns/:kind/:name/kvstore/keys
    cvaroqui committed Aug 26, 2024
    Configuration menu
    Copy the full SHA
    7be39d0 View commit details
    Browse the repository at this point in the history
  4. Make the client code do the keystore --from to []byte work

    This code was in object.Keystore instances. Move it to util/uri
    so omcmd and oxcmd can use it.
    
    Remove these from the Keystore interface:
    
    * AddKeyFrom
    * PrepareAddKeyFrom
    * ChangeKeyFrom
    * PrepareChangeKeyFrom
    
    It's much more sane to have the client download or read local
    files himself, instead of allowing a read privilege escalation
    via the daemon api or "sudo om cfg add --key".
    cvaroqui committed Aug 26, 2024
    Configuration menu
    Copy the full SHA
    a884906 View commit details
    Browse the repository at this point in the history

Commits on Aug 27, 2024

  1. Configuration menu
    Copy the full SHA
    a696fe0 View commit details
    Browse the repository at this point in the history
  2. Make the kvstore commands work with a object selector

    Example:
    
    root@dev2n1:~/dev/om3# bin/ox system/** keys
    OBJECT          NODE   KEY
    system/sec/ca   dev2n1 private_key
    system/sec/ca   dev2n1 certificate
    system/sec/ca   dev2n1 certificate_chain
    system/sec/ca   dev2n1 fullpem
    system/sec/cert dev2n1 private_key
    system/sec/cert dev2n1 certificate
    system/sec/cert dev2n1 certificate_chain
    system/sec/cert dev2n1 fullpem
    system/usr/cva  dev2n1 password
    cvaroqui committed Aug 27, 2024
    Configuration menu
    Copy the full SHA
    d98ffe7 View commit details
    Browse the repository at this point in the history
  3. Add the value size to "om ** keys" items

    Example:
    
    	$ bin/ox '**' keys
    	OBJECT          NODE   KEY               SIZE
    	system/sec/cert dev2n1 private_key       4606
    	system/sec/cert dev2n1 certificate       2582
    	system/sec/cert dev2n1 certificate_chain 4658
    	system/sec/cert dev2n1 fullpem           8982
    	test/cfg/hdoc   dev2n1 config.json       1159
    	test/cfg/hdoc   dev2n1 foo1              15
    	test/cfg/hdoc   dev2n1 hosts             8
    	test/cfg/hdoc   dev2n1 protocols         4199
    	test/cfg/hdoc   dev2n1 foo2              4199
    	system/sec/ca   dev2n1 private_key       4606
    	system/sec/ca   dev2n1 certificate       2642
    	system/sec/ca   dev2n1 certificate_chain 2642
    	system/sec/ca   dev2n1 fullpem           6962
    	system/usr/cva  dev2n1 password          194
    	cfg/foo2        dev2n2 foo               11
    cvaroqui committed Aug 27, 2024
    Configuration menu
    Copy the full SHA
    22fcfe3 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    7a67709 View commit details
    Browse the repository at this point in the history

Commits on Aug 28, 2024

  1. kvstore changes

    * Implement the "add|change --from <dir>"
    
    * Make change behave as a upsert. add is the action to use when
    you don't want to overwrite existing keys.
    
    * Use the PATCH /object/path/:ns/:kd/:name/kvstore handler to
    add and change keys, as --from <dir> can feed multiple keys at
    once. The change is transactional: either all or no key changes
    are commited.
    cvaroqui committed Aug 28, 2024
    Configuration menu
    Copy the full SHA
    edbc42d View commit details
    Browse the repository at this point in the history
  2. Fix daemon panic on object.New<interface> uses

    object.New<interface> should verify the type cast worked, and
    raise a new object.ErrWrongType error if not.
    
    The api handlers now emit a "Bad Request" response if they
    get a object.ErrWrongType, and "Internal Server Error" is still
    used for all other errors.
    cvaroqui committed Aug 28, 2024
    Configuration menu
    Copy the full SHA
    2c04e4c View commit details
    Browse the repository at this point in the history
  3. Fix a stack on malformed config update orders

    For example:
    
    	$ om foo set --kw fs#1type=flag
    
    would panic on:
    
    	panic: runtime error: invalid memory address or nil pointer dereference
    	[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0xc8b545]
    
    	goroutine 1 [running]:
    	github.com/cvaroqui/ini.(*Key).Value(...)
    	    /root/go/pkg/mod/github.com/cvaroqui/[email protected]/key.go:110
    	github.com/opensvc/om3/core/xconfig.(*T).set.func1({{{0xc003da00d0, 0x8}, {0x0, 0x0}}, 0x1, {0xc003da00d9, 0x4}, 0x0})
    	    /root/dev/om3/core/xconfig/main.go:527 +0x65
    
    Add a test, so that this bogus set would produce a clean:
    
    	Error: invalid key in fs#1type=flag
    cvaroqui committed Aug 28, 2024
    Configuration menu
    Copy the full SHA
    ba3d704 View commit details
    Browse the repository at this point in the history