This repository has been archived by the owner on Sep 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add util functions for publishing message to MQTT topics. address #51
- Loading branch information
1 parent
4467133
commit e2d7c48
Showing
120 changed files
with
15,197 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,9 @@ | |
"api\\.pb\\.go" | ||
], | ||
"deadline": "5m", | ||
"tests": true | ||
"tests": true, | ||
"build-tags": [ | ||
"test" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"signing": { | ||
"default": { | ||
"expiry": "87600h" | ||
}, | ||
"profiles": { | ||
"intermediate": { | ||
"usages": [ | ||
"signing", | ||
"digital signature", | ||
"key encipherment", | ||
"cert sign", | ||
"crl sign", | ||
"server auth", | ||
"client auth" | ||
], | ||
"expiry": "87600h", | ||
"is_ca": true, | ||
"ca_constraint": { | ||
"is_ca": true, | ||
"max_path_len": 0, | ||
"max_path_len_zero": true | ||
} | ||
}, | ||
"peer": { | ||
"usages": [ | ||
"signing", | ||
"digital signature", | ||
"key encipherment", | ||
"server auth", | ||
"client auth" | ||
], | ||
"expiry": "87600h" | ||
}, | ||
"server": { | ||
"usages": [ | ||
"signing", | ||
"digital signing", | ||
"key encipherment", | ||
"server auth" | ||
], | ||
"expiry": "87600h" | ||
}, | ||
"client": { | ||
"usages": [ | ||
"signing", | ||
"digital signature", | ||
"key encipherment", | ||
"client auth" | ||
], | ||
"expiry": "87600h" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env bash | ||
|
||
function octopus::cfssl::install() { | ||
tmp_dir=$(mktemp -d) | ||
pushd "${tmp_dir}" >/dev/null || exit 1 | ||
go mod init tmp | ||
go get github.com/cloudflare/cfssl/cmd/... | ||
rm -rf "${tmp_dir}" | ||
popd >/dev/null || return | ||
} | ||
|
||
function octopus::cfssl::validate() { | ||
if [[ -n "$(command -v cfssl)" ]] || [[ -n "$(command -v cfssljson)" ]]; then | ||
return 0 | ||
fi | ||
|
||
octopus::log::info "installing cfssl" | ||
if octopus::cfssl::install; then | ||
octopus::log::info "$(cfssl version 2>&1)" | ||
return 0 | ||
fi | ||
octopus::log::error "no cfssl available" | ||
return 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package v1alpha1 | ||
|
||
// ReferencesHandler is a convenient `map[string]*ConnectRequestReferenceEntry` handler for obtaining data while avoiding the nil pointer error. | ||
type ReferencesHandler map[string]*ConnectRequestReferenceEntry | ||
|
||
// GetData returns the data of specified name and itemName, | ||
// it's always return nil if the data bytes is not existed or empty. | ||
func (h ReferencesHandler) GetData(name, itemName string) []byte { | ||
if len(h) == 0 { | ||
return nil | ||
} | ||
|
||
var refItems, refExist = h[name] | ||
if !refExist || len(refItems.Items) == 0 { | ||
return nil | ||
} | ||
|
||
var refItem, refItemExist = refItems.Items[itemName] | ||
if !refItemExist { | ||
return nil | ||
} | ||
|
||
if len(refItem) == 0 { | ||
return nil | ||
} | ||
return refItem | ||
} | ||
|
||
// ToDataMap returns a `map[string]map[string][]byte` that constructed the references data, | ||
// it's always return nil if the references is nil or empty. | ||
func (h ReferencesHandler) ToDataMap() map[string]map[string][]byte { | ||
if len(h) == 0 { | ||
return nil | ||
} | ||
|
||
var refMap = make(map[string]map[string][]byte, len(h)) | ||
for refKey, refValue := range h { | ||
if refValue == nil || len(refValue.Items) == 0 { | ||
continue | ||
} | ||
var refItems = make(map[string][]byte, len(refValue.Items)) | ||
for refItemKey, refItemValue := range refValue.Items { | ||
refItems[refItemKey] = refItemValue | ||
} | ||
refMap[refKey] = refItems | ||
} | ||
return refMap | ||
} | ||
|
||
// GetReferencesHandler returns a ReferencesHandler for obtaining data. | ||
func (m *ConnectRequest) GetReferencesHandler() ReferencesHandler { | ||
if m != nil { | ||
return m.References | ||
} | ||
return nil | ||
} |
Oops, something went wrong.