Skip to content

Commit

Permalink
Merge pull request #1299 from pkulik0/remove-pat-from-sdk-workflow
Browse files Browse the repository at this point in the history
Changes to Update-SDK workflow
  • Loading branch information
pkulik0 authored Aug 8, 2024
2 parents 8706de4 + 958d0f1 commit 560b7de
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/update-sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ jobs:
repository: ${{ github.event.inputs.sdk-repo }}
ref: ${{ github.event.inputs.sdk-version }}
path: ./sdk
token: ${{ secrets.PAT }}

- name: Setup Go
uses: actions/setup-go@v5
Expand All @@ -46,11 +45,12 @@ jobs:
SDK_VERSION: ${{ github.event.inputs.sdk-version }}
run: |
# Remove all in case some files are removed
rm -rf .[!.]* *
shopt -s nullglob
rm -rf .[!.git]* *
cp -r $PROJECT/pkg/.[^.]* $PROJECT/pkg/* $PROJECT/go.mod .
# Replace module references
find . -type f -exec sed -i "s|github.com/canonical/jimm/pkg|github.com/$SDK_REPO/$SDK_VERSION|" {} +
find . -type f -exec sed -i "s|github.com/canonical/jimm/v3/pkg|github.com/$SDK_REPO/$SDK_VERSION|" {} +
sed -i "s|module .*|module github.com/$SDK_REPO/$SDK_VERSION|" go.mod
# Needed to remove unused dependencies
Expand All @@ -59,7 +59,7 @@ jobs:
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.PAT }}
token: ${{ secrets.JIMM_GO_SDK_PAT }}
path: ./sdk
branch: update-sdk-${{ github.run_number }}
title: Update SDK ${{ github.event.inputs.sdk-version }}
Expand Down
9 changes: 7 additions & 2 deletions pkg/names/service_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
package names

import (
"errors"
"fmt"
"strings"

"github.com/canonical/jimm/v3/internal/errors"
"github.com/juju/names/v5"
)

Expand All @@ -20,6 +20,11 @@ const (
ServiceAccountDomain = "serviceaccount"
)

var (
// ErrInvalidClientID indicates an invalid client ID error.
ErrInvalidClientID = errors.New("invalid client ID")
)

// Service accounts are an OIDC/OAuth concept which allows for machine<->machine communication.
// Service accounts are identified by their client ID.

Expand Down Expand Up @@ -81,7 +86,7 @@ func EnsureValidServiceAccountId(id string) (string, error) {
}

if !IsValidServiceAccountId(id) {
return "", errors.E(errors.CodeBadRequest, "invalid client ID")
return "", ErrInvalidClientID
}
return id, nil
}

0 comments on commit 560b7de

Please sign in to comment.