Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sapcc/go-openstack-auth
Go openstack auth v3 for getting tokens and endpoints
https://github.com/sapcc/go-openstack-auth
Last synced: 11 days ago
JSON representation
Go openstack auth v3 for getting tokens and endpoints
- Host: GitHub
- URL: https://github.com/sapcc/go-openstack-auth
- Owner: sapcc
- License: apache-2.0
- Created: 2019-03-05T13:50:18.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T08:41:26.000Z (11 months ago)
- Last Synced: 2023-12-15T09:48:14.840Z (11 months ago)
- Language: Go
- Size: 14.6 KB
- Stars: 3
- Watchers: 37
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-openstack-auth
Go openstack auth v3 for getting tokens and endpointsExample:
import (
auth "github.com/sapcc/go-openstack-auth"
)options := auth.AuthV3Options{
IdentityEndpoint: viper.GetString(ENV_VAR_AUTH_URL),
Region: viper.GetString(ENV_VAR_REGION),
Username: viper.GetString(ENV_VAR_USERNAME),
UserId: viper.GetString(ENV_VAR_USER_ID),
Password: viper.GetString(ENV_VAR_PASSWORD),
ProjectName: viper.GetString(ENV_VAR_PROJECT_NAME),
ProjectId: viper.GetString(ENV_VAR_PROJECT_ID),
UserDomainName: viper.GetString(ENV_VAR_USER_DOMAIN_NAME),
UserDomainId: viper.GetString(ENV_VAR_USER_DOMAIN_ID),
ProjectDomainName: viper.GetString(ENV_VAR_PROJECT_DOMAIN_NAME),
ProjectDomainId: viper.GetString(ENV_VAR_PROJECT_DOMAIN_ID),
}authV3 := auth.AuthenticationV3(options)
token, err := authV3.GetToken()
if err != nil {
fmt.Println(err)
}fmt.Println("°°°TOKEN°°°")
fmt.Println(token.ID)
fmt.Println("°°°")endpoint, err := authV3.GetServiceEndpoint("arc", "staging", "public")
if err != nil {
fmt.Println(err)
}fmt.Println("°°°ENDPOINT°°°")
fmt.Println(endpoint)
fmt.Println("°°°")For testing use the mock object:
import (
auth "github.com/sapcc/go-openstack-auth"
)func TestMock(t *testing.T) {
auth.AuthenticationV3 = auth.NewMockAuthenticationV3
auth.CommonResult1 = map[string]interface{}{"token": map[string]interface{}{"project": map[string]string{"id": "test_project_id", "domain_id": "test_domain_id", "name": "Arc_Test"}}}
}