mirror of
https://github.com/psviderski/uncloud.git
synced 2026-10-06 13:18:58 +00:00
add uncloud machine init command to initialise a new cluster on local machine
This commit is contained in:
1 parent
58fb3105cd
commit
3f71aec275
7 files changed
+222
-53
No files matched your search
@@ -9,6 +9,15 @@ import (
|
||||
|
||||
type Secret []byte
|
||||
|
||||
// FromHexString parses a hex-encoded string into a secret.
|
||||
func FromHexString(s string) (Secret, error) {
|
||||
decoded, err := hex.DecodeString(s)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid hex-encoded secret: %w", err)
|
||||
}
|
||||
return decoded, nil
|
||||
}
|
||||
|
||||
// String returns the hex-encoded string representation of the secret.
|
||||
//
|
||||
//goland:noinspection GoMixedReceiverTypes
|
||||
@@ -23,11 +32,11 @@ func (s Secret) MarshalText() ([]byte, error) {
|
||||
|
||||
//goland:noinspection GoMixedReceiverTypes
|
||||
func (s *Secret) UnmarshalText(text []byte) error {
|
||||
decoded, err := hex.DecodeString(string(text))
|
||||
secret, err := FromHexString(string(text))
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid hex-encoded secret: %w", err)
|
||||
return err
|
||||
}
|
||||
*s = decoded
|
||||
*s = secret
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user