Skip to content

Commit

Permalink
chore: Vaults and groups always uses latest as contract id and releas…
Browse files Browse the repository at this point in the history
…e of v1.3.5
  • Loading branch information
maikelpoot committed Jun 28, 2024
1 parent b0bdba5 commit c4a5ee7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]


## [1.3.5] - 2024-06-25
### Changed
- Issue # : Vaults and groups always uses latest as contract id

## [1.3.4] - 2024-06-25
### Fixed
- Issue # : Fix incorrect check for no supported versions
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ retract (
v1.3.1
v1.3.2
v1.3.3
v1.3.4
)


Expand Down
16 changes: 8 additions & 8 deletions keyhub.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func NewClient(httpClient *http.Client, issuer string, clientID string, clientSe

var err error
var baseVersionedSupported bool
var newerVersionedSupported bool
var latestVersionedSupported bool

base := sling.New().Client(httpClient).Base(issuer)

Expand All @@ -97,14 +97,14 @@ func NewClient(httpClient *http.Client, issuer string, clientID string, clientSe
}

// Create sling for contract version 71
newerVersionedSling := base.New()
newerVersionedSupported, err = versionService.CheckAndUpdateVersionedSling(71, newerVersionedSling)
latestVersionedSling := base.New()
latestVersionedSupported, err = versionService.CheckAndUpdateVersionedSling(0, latestVersionedSling)
if err != nil {
newClient.VersionErrors = append(newClient.VersionErrors, err)
}

if !(baseVersionedSupported || newerVersionedSupported) {
return nil, fmt.Errorf("KeyHub %v does not support api contract versions 60 or 71", versionService.info.KeyhubVersion)
if !(baseVersionedSupported || latestVersionedSupported) {
return nil, fmt.Errorf("KeyHub %v does not support api contract versions 60 or Latest", versionService.info.KeyhubVersion)
}

ctx := oidc.ClientContext(context.Background(), httpClient)
Expand Down Expand Up @@ -138,9 +138,9 @@ func NewClient(httpClient *http.Client, issuer string, clientID string, clientSe
newClient.ServiceAccounts = NewServiceAccountService(oauth2Sling)
}

if newerVersionedSupported {
newClient.Groups = newGroupService(newerVersionedSling.New().Client(oauth2Client))
newClient.Vaults = newVaultService(newerVersionedSling.New().Client(vaultClient))
if latestVersionedSupported {
newClient.Groups = newGroupService(latestVersionedSling.New().Client(oauth2Client))
newClient.Vaults = newVaultService(latestVersionedSling.New().Client(vaultClient))
}

return newClient, nil
Expand Down
1 change: 1 addition & 0 deletions version.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func (s *VersionService) CheckAndUpdateVersionedSling(version int, base *sling.S

headerVersion = fmt.Sprintf("%d", version)
} else {
isSupported = true
headerVersion = "latest"
}

Expand Down

0 comments on commit c4a5ee7

Please sign in to comment.