Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCALRCORE-28034 [go-scalr] Provider > Ignore draft PR #133

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 27 additions & 24 deletions vcs_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,16 @@ type OAuth struct {

// VcsProvider represents a Scalr IACP VcsProvider.
type VcsProvider struct {
ID string `jsonapi:"primary,vcs-providers"`
Name string `jsonapi:"attr,name"`
Url string `jsonapi:"attr,url"`
VcsType VcsType `jsonapi:"attr,vcs-type"`
AuthType AuthType `jsonapi:"attr,auth-type"`
OAuth *OAuth `jsonapi:"attr,oauth"`
Token *string `jsonapi:"attr,token"`
Username *string `jsonapi:"attr,username"`
IsShared bool `jsonapi:"attr,is-shared"`
ID string `jsonapi:"primary,vcs-providers"`
Name string `jsonapi:"attr,name"`
Url string `jsonapi:"attr,url"`
VcsType VcsType `jsonapi:"attr,vcs-type"`
AuthType AuthType `jsonapi:"attr,auth-type"`
OAuth *OAuth `jsonapi:"attr,oauth"`
Token *string `jsonapi:"attr,token"`
Username *string `jsonapi:"attr,username"`
IsShared bool `jsonapi:"attr,is-shared"`
DraftPrRunsEnabled bool `jsonapi:"attr,draft-pr-runs-enabled"`

// Relations
Environments []*Environment `jsonapi:"relation,environments"`
Expand Down Expand Up @@ -119,15 +120,16 @@ func (s *vcsProviders) List(ctx context.Context, options VcsProvidersListOptions

// VcsProviderCreateOptions represents the options for creating a new vcs provider.
type VcsProviderCreateOptions struct {
ID string `jsonapi:"primary,vcs-providers"`
Name *string `jsonapi:"attr,name"`
VcsType VcsType `jsonapi:"attr,vcs-type"`
AuthType AuthType `jsonapi:"attr,auth-type"`
OAuth *OAuth `jsonapi:"attr,oauth"`
Token string `jsonapi:"attr,token"`
Url *string `jsonapi:"attr,url"`
Username *string `jsonapi:"attr,username"`
IsShared *bool `jsonapi:"attr,is-shared,omitempty"`
ID string `jsonapi:"primary,vcs-providers"`
Name *string `jsonapi:"attr,name"`
VcsType VcsType `jsonapi:"attr,vcs-type"`
AuthType AuthType `jsonapi:"attr,auth-type"`
OAuth *OAuth `jsonapi:"attr,oauth"`
Token string `jsonapi:"attr,token"`
Url *string `jsonapi:"attr,url"`
Username *string `jsonapi:"attr,username"`
IsShared *bool `jsonapi:"attr,is-shared,omitempty"`
DraftPrRunsEnabled *bool `jsonapi:"attr,draft-pr-runs-enabled,omitempty"`

// Relations
Environments []*Environment `jsonapi:"relation,environments,omitempty"`
Expand Down Expand Up @@ -178,12 +180,13 @@ func (s *vcsProviders) Read(ctx context.Context, vcsProviderID string) (*VcsProv
// VcsProviderUpdateOptions represents the options for updating a vcs provider.
type VcsProviderUpdateOptions struct {
// For internal use only!
ID string `jsonapi:"primary,vcs-providers"`
Name *string `jsonapi:"attr,name,omitempty"`
Token *string `jsonapi:"attr,token,omitempty"`
Url *string `jsonapi:"attr,url,omitempty"`
Username *string `jsonapi:"attr,username,omitempty"`
IsShared *bool `jsonapi:"attr,is-shared,omitempty"`
ID string `jsonapi:"primary,vcs-providers"`
Name *string `jsonapi:"attr,name,omitempty"`
Token *string `jsonapi:"attr,token,omitempty"`
Url *string `jsonapi:"attr,url,omitempty"`
Username *string `jsonapi:"attr,username,omitempty"`
IsShared *bool `jsonapi:"attr,is-shared,omitempty"`
DraftPrRunsEnabled *bool `jsonapi:"attr,draft-pr-runs-enabled,omitempty"`

// Relations
Environments []*Environment `jsonapi:"relation,environments"`
Expand Down
11 changes: 7 additions & 4 deletions vcs_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ func TestVcsProvidersCreate(t *testing.T) {

t.Run("with valid options", func(t *testing.T) {
options := VcsProviderCreateOptions{
Name: String("vcs-" + randomString(t)),
VcsType: Github,
AuthType: PersonalToken,
Token: os.Getenv("GITHUB_TOKEN"),
Name: String("vcs-" + randomString(t)),
VcsType: Github,
AuthType: PersonalToken,
Token: os.Getenv("GITHUB_TOKEN"),
DraftPrRunsEnabled: Bool(true),

Environments: []*Environment{envTest},
Account: &Account{ID: defaultAccountID},
Expand All @@ -91,6 +92,7 @@ func TestVcsProvidersCreate(t *testing.T) {
assert.Equal(t, options.VcsType, item.VcsType)
assert.Equal(t, options.AuthType, item.AuthType)
assert.Equal(t, false, item.IsShared)
assert.Equal(t, true, item.DraftPrRunsEnabled)
}
})

Expand All @@ -113,6 +115,7 @@ func TestVcsProvidersCreate(t *testing.T) {
assert.Equal(t, options.VcsType, vcs.VcsType)
assert.Equal(t, options.AuthType, vcs.AuthType)
assert.Equal(t, *options.IsShared, vcs.IsShared)
assert.Equal(t, false, vcs.DraftPrRunsEnabled)

})

Expand Down
Loading