Skip to content

Commit

Permalink
Fix bugs (#1)
Browse files Browse the repository at this point in the history
* Add logging to debug

* Enable pushing to docker registry

* Fix a bug

* Fix a bug

* Add writable permissions for manager

Co-authored-by: Tsuzu <cs3238-tsuzu@users.noreply.github.com>
  • Loading branch information
tsuzu and Tsuzu authored Sep 17, 2020
1 parent 87b2969 commit 96f68f3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
dockerfile: Dockerfile
tag_with_ref: true
tag_with_sha: true
push: ${{ github.event_name == 'push' }}
push: true
10 changes: 1 addition & 9 deletions api/v1alpha1/clustergithubapp_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ package v1alpha1

import (
"context"
"encoding/base64"
"os"

"github.com/modoki-paas/ghapp-controller/pkg/ghatypes"
"golang.org/x/xerrors"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -117,11 +115,5 @@ func (a *ClusterGitHubApp) GetPrivateKey(ctx context.Context, c client.Client) (
return nil, ghatypes.ErrKeyNotFound
}

decoded, err := base64.StdEncoding.DecodeString(string(data))

if err != nil {
return nil, xerrors.Errorf("failed to parse base64-encoded key: %w", err)
}

return decoded, nil
return data, nil
}
5 changes: 5 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ rules:
resources:
- secrets
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ghapp.tsuzu.dev
resources:
Expand Down
2 changes: 1 addition & 1 deletion controllers/installation_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type InstallationReconciler struct {
// +kubebuilder:rbac:groups=ghapp.tsuzu.dev,resources=installations/status,verbs=get;update;patch
// +kubebuilder:rbac:groups=ghapp.tsuzu.dev,resources=clustergithubapps,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=ghapp.tsuzu.dev,resources=clustergithubapps/status,verbs=get;update;patch
// +kubebuilder:rbac:groups=core,resources=secrets,verbs=get;list
// +kubebuilder:rbac:groups=core,resources=secrets,verbs=get;list;watch;create;update;patch;delete

func (r *InstallationReconciler) Reconcile(req ctrl.Request) (res ctrl.Result, err error) {
ctx := context.Background()
Expand Down
4 changes: 4 additions & 0 deletions pkg/installations/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ func (c *Client) generate(ctx context.Context, gha ghatypes.GitHubAppInterface,

generated.Annotations[SecretExpiredAtAnnotationKey] = token.GetExpiresAt().Format(time.RFC3339)
generated.Annotations[SecretHashAnnotationKey] = hash

if generated.StringData == nil {
generated.StringData = map[string]string{}
}
generated.StringData[c.Installation.Spec.Key] = token.GetToken()

return &generated
Expand Down

0 comments on commit 96f68f3

Please sign in to comment.