Skip to content

Commit

Permalink
Fix region
Browse files Browse the repository at this point in the history
  • Loading branch information
bmassemin committed Sep 30, 2024
1 parent 9ec7c62 commit 1c6eb68
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,23 @@

SSO Client for OVH

## Usage

OVH SDKs are able to read the `ovh.conf` file and fetch the credentials from it.
It also includes the Terraform provider. For instance, you can set up the Terraform provider this way:
```hcl
provider "ovh" {
endpoint = "ovh-eu"
}
```

Then, run ovh-oauth2cli in the Terraform root directory. You should be able to execute a terraform plan.\
⚠️ Don't forget to add ovh.conf to your .gitignore file.

## Installation

```
go install github.com/bmassemin/ovh-oauth2cli@latest
go install github.com/bmassemin/ovh-oauth2cli@v0.0.2
```

## OVH Configuration
Expand Down
12 changes: 6 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,20 @@ Then set the following options:`)
if err != nil {
return fmt.Errorf("could not get a token: %w", err)
}
setEnvVar(token.AccessToken)
setEnvVar(o.region, token.AccessToken)
return nil
})
if err := eg.Wait(); err != nil {
log.Fatalf("authorization error: %s", err)
}
}

func setEnvVar(accessToken string) {
confFile := `[default]
endpoint=ovh-eu
func setEnvVar(region string, accessToken string) {
confFile := fmt.Sprintf(`[default]
endpoint=ovh-%s
[ovh-eu]
access_token=` + accessToken
[ovh-%s]
access_token=%s`, region, region, accessToken)
os.WriteFile("ovh.conf", []byte(confFile), 0644)
}

Expand Down

0 comments on commit 1c6eb68

Please sign in to comment.