infobloxopen / atlas-app-toolkit

This repository provides common Go utilities and helpers that are reusable from project-to-project. The goal is to prevent code duplication by encouraging teams to use and contribute to toolkit libraries. The toolkit is not a framework. Rather, it is a set of (mostly gRPC-related) plugins and helpers.
Apache License 2.0
99 stars 115 forks source link

bloxid: need a way to create a bloxid object by passing the unique id of a bloxid random scheme in constructor #309

Closed wplu closed 2 years ago

wplu commented 2 years ago

There isn't a way to create a new bloxid object by passing the unique id of a previously generated random scheme bloxid. In the database, we only store the unique id portion of the bloxid. We need a way to reconstitute the bloxid object. Suggestion:

add WithScheme(WithRandomEncodedID(encodedID string)) to V0 constructor option:

v0, err := NewV0("",
            WithEntityDomain("iam"),
            WithEntityType("group"),
            WithRealm("us-com-1"),
            WithSchemer(WithRandomEncodedID('tshwyq3mfkgqqcfa76a5hbr2uaayzw3h'))
        )
// v0.String(): blox0.iam.group.us-com-1.tshwyq3mfkgqqcfa76a5hbr2uaayzw3h
// v0.Encoded(): "tshwyq3mfkgqqcfa76a5hbr2uaayzw3h"
// v0.Decoded(): "9c8f6c436c2a8d0808a0ff81d3863aa0018cdb67"
wplu commented 2 years ago

done