Documentation
¶
Overview ¶
Copyright © 2020 NAME HERE <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2020 NAME HERE <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2020 NAME HERE <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddRepoSecret ¶
func AddRepoSecret(owner string, repo string, secretName string, secretValue string) (string, error)
AddRepoSecret will add a secret value to a given github repo for a given owner It encrypts the secret using sodium before sending the secret to github api therefore requires libsodium to be installed on the machine running this code https://formulae.brew.sh/formula/libsodium Github is very picky over formats things need to be to be sent, and not very descriptive in how they will be sent to the user To get a secret uploaded you need to get the public key of the repo that will be receiving the secret. This key is used to encrypt the secret before transport on the sending side, and then decrypted by github. Once you have the public key you need to encrypt the secret with sodiumlib before sending it. The public key comes base64 encoded, and sodiumlib expects it to not be base64 encoded so you need to decode the public key before using it. Once the public key is decoded you need to convert the string secret into bytes. once you have the public key decoded, and the secret string in bytes you can encrypt it using sodium.CryptoBoxSeal That will produce the correctly encrypted secret as bytes, but you need to then convert it to a base64 encoded string. After doing that you can use that base64 encoded string as the encrypted value to be part of the github.EncodedSecret type. The name is the string (no encoding, or base64 needed) of the secret name that will appear in github secrets then the KeyID will be the public key of the repo's ID, which is gettable from the public key's GetKeyID method. Finally you can pass that object in and have it be created or updated in github.
Types ¶
This section is empty.