Skip to content

Commit

Permalink
Improve log lines to match with implementation (sigstore#1432)
Browse files Browse the repository at this point in the history
Signed-off-by: Marco Franssen <[email protected]>
  • Loading branch information
marcofranssen authored and mlieberman85 committed May 6, 2022
1 parent 51ae750 commit 46e497e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pkg/cosign/git/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ func (g *Gh) PutSecret(ctx context.Context, ref string, pf cosign.PassFunc) erro

passwordSecretEnvResp, err := client.Actions.CreateOrUpdateRepoSecret(ctx, owner, repo, passwordSecretEnv)
if err != nil {
return errors.Wrap(err, "could not create \"COSIGN_PASSWORD\" environment variable")
return errors.Wrap(err, "could not create \"COSIGN_PASSWORD\" github actions secret")
}

if passwordSecretEnvResp.StatusCode < 200 && passwordSecretEnvResp.StatusCode >= 300 {
bodyBytes, _ := io.ReadAll(passwordSecretEnvResp.Body)
return fmt.Errorf("%s", bodyBytes)
}

fmt.Fprintln(os.Stderr, "Private key written to COSIGN_PASSWORD environment variable")
fmt.Fprintln(os.Stderr, "Password written to COSIGN_PASSWORD github actions secret")

privateKeySecretEnv := &github.EncryptedSecret{
Name: "COSIGN_PRIVATE_KEY",
Expand All @@ -100,15 +100,15 @@ func (g *Gh) PutSecret(ctx context.Context, ref string, pf cosign.PassFunc) erro

privateKeySecretEnvResp, err := client.Actions.CreateOrUpdateRepoSecret(ctx, owner, repo, privateKeySecretEnv)
if err != nil {
return errors.Wrap(err, "could not create \"COSIGN_PRIVATE_KEY\" environment variable")
return errors.Wrap(err, "could not create \"COSIGN_PRIVATE_KEY\" github actions secret")
}

if privateKeySecretEnvResp.StatusCode < 200 && privateKeySecretEnvResp.StatusCode >= 300 {
bodyBytes, _ := io.ReadAll(privateKeySecretEnvResp.Body)
return fmt.Errorf("%s", bodyBytes)
}

fmt.Fprintln(os.Stderr, "Private key written to COSIGN_PRIVATE_KEY environment variable")
fmt.Fprintln(os.Stderr, "Private key written to COSIGN_PRIVATE_KEY github actions secret")

publicKeySecretEnv := &github.EncryptedSecret{
Name: "COSIGN_PUBLIC_KEY",
Expand All @@ -118,15 +118,15 @@ func (g *Gh) PutSecret(ctx context.Context, ref string, pf cosign.PassFunc) erro

publicKeySecretEnvResp, err := client.Actions.CreateOrUpdateRepoSecret(ctx, owner, repo, publicKeySecretEnv)
if err != nil {
return errors.Wrap(err, "could not create \"COSIGN_PUBLIC_KEY\" environment variable")
return errors.Wrap(err, "could not create \"COSIGN_PUBLIC_KEY\" github actions secret")
}

if publicKeySecretEnvResp.StatusCode < 200 && publicKeySecretEnvResp.StatusCode >= 300 {
bodyBytes, _ := io.ReadAll(publicKeySecretEnvResp.Body)
return fmt.Errorf("%s", bodyBytes)
}

fmt.Fprintln(os.Stderr, "Public key written to COSIGN_PUBLIC_KEY environment variable")
fmt.Fprintln(os.Stderr, "Public key written to COSIGN_PUBLIC_KEY github actions secret")

if err := os.WriteFile("cosign.pub", keys.PublicBytes, 0o600); err != nil {
return err
Expand Down

0 comments on commit 46e497e

Please sign in to comment.