Skip to content

Commit 77c82c6

Browse files
authored
Merge pull request #106 from Scalr/revert-104-feature/SCALRCORE-24861
Revert "Provider > Add link API between on-prem VCS and Agent-Pool "
2 parents 50e72bb + f0963a5 commit 77c82c6

File tree

9 files changed

+27
-101
lines changed

9 files changed

+27
-101
lines changed

access_token_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func TestAccessTokenRead(t *testing.T) {
1313
client := testClient(t)
1414
ctx := context.Background()
1515

16-
ap, apCleanup := createAgentPool(t, client, false)
16+
ap, apCleanup := createAgentPool(t, client)
1717
defer apCleanup()
1818

1919
atTest, atTestCleanup := createAgentPoolToken(t, client, ap.ID)
@@ -40,7 +40,7 @@ func TestAccessTokenUpdate(t *testing.T) {
4040
client := testClient(t)
4141
ctx := context.Background()
4242

43-
ap, apCleanup := createAgentPool(t, client, false)
43+
ap, apCleanup := createAgentPool(t, client)
4444
defer apCleanup()
4545

4646
apt, aptCleanup := createAgentPoolToken(t, client, ap.ID)
@@ -75,7 +75,7 @@ func TestAccessTokenDelete(t *testing.T) {
7575
client := testClient(t)
7676
ctx := context.Background()
7777

78-
ap, apCleanup := createAgentPool(t, client, false)
78+
ap, apCleanup := createAgentPool(t, client)
7979
defer apCleanup()
8080

8181
apt, _ := createAgentPoolToken(t, client, ap.ID)

agent_pool.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ type AgentPoolList struct {
3434

3535
// AgentPool represents a Scalr agent pool.
3636
type AgentPool struct {
37-
ID string `jsonapi:"primary,agent-pools"`
38-
Name string `jsonapi:"attr,name"`
39-
VcsEnabled bool `jsonapi:"attr,vcs-enabled"`
37+
ID string `jsonapi:"primary,agent-pools"`
38+
Name string `jsonapi:"attr,name"`
39+
4040
// Relations
4141

4242
// The agent pool's scope
@@ -51,9 +51,8 @@ type AgentPool struct {
5151

5252
// AgentPoolCreateOptions represents the options for creating a new AgentPool.
5353
type AgentPoolCreateOptions struct {
54-
ID string `jsonapi:"primary,agent-pools"`
55-
Name *string `jsonapi:"attr,name"`
56-
VcsEnabled *bool `jsonapi:"attr,vcs-enabled,omitempty"`
54+
ID string `jsonapi:"primary,agent-pools"`
55+
Name *string `jsonapi:"attr,name"`
5756

5857
// The agent pool's scope
5958
Account *Account `jsonapi:"relation,account"`
@@ -97,7 +96,6 @@ type AgentPoolListOptions struct {
9796
Environment *string `url:"filter[environment],omitempty"`
9897
Name string `url:"filter[name],omitempty"`
9998
AgentPool string `url:"filter[agent-pool],omitempty"`
100-
VcsEnabled *bool `url:"filter[vcs-enabled],omitempty"`
10199
Include string `url:"include,omitempty"`
102100
}
103101

agent_pool_test.go

Lines changed: 7 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@ func TestAgentPoolsList(t *testing.T) {
1313
client := testClient(t)
1414
ctx := context.Background()
1515

16-
agentPoolTest1, agentPoolTest1Cleanup := createAgentPool(t, client, false)
16+
agentPoolTest1, agentPoolTest1Cleanup := createAgentPool(t, client)
1717
defer agentPoolTest1Cleanup()
18-
agentPoolTest2, agentPoolTest2Cleanup := createAgentPool(t, client, true)
18+
agentPoolTest2, agentPoolTest2Cleanup := createAgentPool(t, client)
1919
defer agentPoolTest2Cleanup()
20-
agentPoolTest3, agentPoolTest3Cleanup := createAgentPool(t, client, true)
21-
defer agentPoolTest3Cleanup()
2220

2321
t.Run("without options", func(t *testing.T) {
2422
apList, err := client.AgentPools.List(ctx, AgentPoolListOptions{})
@@ -29,7 +27,6 @@ func TestAgentPoolsList(t *testing.T) {
2927
}
3028
assert.Contains(t, apListIDs, agentPoolTest1.ID)
3129
assert.Contains(t, apListIDs, agentPoolTest2.ID)
32-
assert.Contains(t, apListIDs, agentPoolTest3.ID)
3330
})
3431
t.Run("with account filter", func(t *testing.T) {
3532
apList, err := client.AgentPools.List(ctx, AgentPoolListOptions{Account: String(defaultAccountID)})
@@ -40,7 +37,6 @@ func TestAgentPoolsList(t *testing.T) {
4037
}
4138
assert.Contains(t, apListIDs, agentPoolTest1.ID)
4239
assert.Contains(t, apListIDs, agentPoolTest2.ID)
43-
assert.Contains(t, apListIDs, agentPoolTest3.ID)
4440
})
4541
t.Run("with account and name filter", func(t *testing.T) {
4642
apList, err := client.AgentPools.List(ctx, AgentPoolListOptions{Account: String(defaultAccountID), Name: agentPoolTest1.Name})
@@ -54,52 +50,13 @@ func TestAgentPoolsList(t *testing.T) {
5450
assert.Len(t, apList.Items, 1)
5551
assert.Equal(t, apList.Items[0].ID, agentPoolTest2.ID)
5652
})
57-
t.Run("with vcs-enabled filter", func(t *testing.T) {
58-
var vcsEnabledFiler = true
59-
apList, err := client.AgentPools.List(ctx, AgentPoolListOptions{VcsEnabled: &vcsEnabledFiler})
60-
require.NoError(t, err)
61-
apListIDs := make([]string, 0)
62-
for _, agentPool := range apList.Items {
63-
apListIDs = append(apListIDs, agentPool.ID)
64-
}
65-
assert.Len(t, apListIDs, 2)
66-
assert.Contains(t, apListIDs, agentPoolTest2.ID)
67-
assert.Contains(t, apListIDs, agentPoolTest3.ID)
68-
})
6953
}
7054

7155
func TestAgentPoolsCreate(t *testing.T) {
7256
client := testClient(t)
7357
ctx := context.Background()
7458

7559
t.Run("when account and name are provided", func(t *testing.T) {
76-
options := AgentPoolCreateOptions{
77-
Account: &Account{ID: defaultAccountID},
78-
Name: String("test-provider-pool-" + randomString(t)),
79-
VcsEnabled: Bool(true),
80-
}
81-
82-
agentPool, err := client.AgentPools.Create(ctx, options)
83-
require.NoError(t, err)
84-
85-
// Get a refreshed view from the API.
86-
refreshed, err := client.AgentPools.Read(ctx, agentPool.ID)
87-
require.NoError(t, err)
88-
89-
for _, item := range []*AgentPool{
90-
agentPool,
91-
refreshed,
92-
} {
93-
assert.NotEmpty(t, item.ID)
94-
assert.Equal(t, *options.Name, item.Name)
95-
assert.Equal(t, options.Account, item.Account)
96-
assert.Equal(t, *options.VcsEnabled, item.VcsEnabled)
97-
}
98-
err = client.AgentPools.Delete(ctx, agentPool.ID)
99-
require.NoError(t, err)
100-
})
101-
102-
t.Run("when create without vcs_enabled", func(t *testing.T) {
10360
options := AgentPoolCreateOptions{
10461
Account: &Account{ID: defaultAccountID},
10562
Name: String("test-provider-pool-" + randomString(t)),
@@ -117,7 +74,8 @@ func TestAgentPoolsCreate(t *testing.T) {
11774
refreshed,
11875
} {
11976
assert.NotEmpty(t, item.ID)
120-
assert.Equal(t, item.VcsEnabled, false)
77+
assert.Equal(t, *options.Name, item.Name)
78+
assert.Equal(t, options.Account, item.Account)
12179
}
12280
err = client.AgentPools.Delete(ctx, agentPool.ID)
12381
require.NoError(t, err)
@@ -132,7 +90,6 @@ func TestAgentPoolsCreate(t *testing.T) {
13290
Account: &Account{ID: defaultAccountID},
13391
Environment: &Environment{ID: env.ID},
13492
Name: String("test-provider-pool-" + randomString(t)),
135-
VcsEnabled: Bool(false),
13693
}
13794

13895
agentPool, err := client.AgentPools.Create(ctx, options)
@@ -166,7 +123,6 @@ func TestAgentPoolsCreate(t *testing.T) {
166123
Environment: &Environment{ID: env.ID},
167124
Workspaces: []*Workspace{{ID: ws.ID}},
168125
Name: String("test-provider-pool-" + randomString(t)),
169-
VcsEnabled: Bool(false),
170126
}
171127

172128
agentPool, err := client.AgentPools.Create(ctx, options)
@@ -285,7 +241,7 @@ func TestAgentPoolsRead(t *testing.T) {
285241
client := testClient(t)
286242
ctx := context.Background()
287243

288-
agentPoolTest, agentPoolTestCleanup := createAgentPool(t, client, false)
244+
agentPoolTest, agentPoolTestCleanup := createAgentPool(t, client)
289245
defer agentPoolTestCleanup()
290246

291247
t.Run("when the agentPool exists", func(t *testing.T) {
@@ -322,7 +278,7 @@ func TestAgentPoolsUpdate(t *testing.T) {
322278
client := testClient(t)
323279
ctx := context.Background()
324280

325-
agentPoolTest, agentPoolTestCleanup := createAgentPool(t, client, false)
281+
agentPoolTest, agentPoolTestCleanup := createAgentPool(t, client)
326282
defer agentPoolTestCleanup()
327283

328284
t.Run("when updating a name", func(t *testing.T) {
@@ -381,7 +337,7 @@ func TestAgentPoolsDelete(t *testing.T) {
381337
client := testClient(t)
382338
ctx := context.Background()
383339

384-
pool, _ := createAgentPool(t, client, false)
340+
pool, _ := createAgentPool(t, client)
385341

386342
t.Run("with valid agent pool id", func(t *testing.T) {
387343
err := client.AgentPools.Delete(ctx, pool.ID)

agent_pool_token_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func TestAgentPoolTokenList(t *testing.T) {
1313
client := testClient(t)
1414
ctx := context.Background()
1515

16-
ap, apCleanup := createAgentPool(t, client, false)
16+
ap, apCleanup := createAgentPool(t, client)
1717
defer apCleanup()
1818

1919
apt, aptCleanup := createAgentPoolToken(t, client, ap.ID)
@@ -41,7 +41,7 @@ func TestAgentPoolTokenCreate(t *testing.T) {
4141
client := testClient(t)
4242
ctx := context.Background()
4343

44-
ap, apCleanup := createAgentPool(t, client, false)
44+
ap, apCleanup := createAgentPool(t, client)
4545
defer apCleanup()
4646

4747
t.Run("when description is provided", func(t *testing.T) {

helper_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,11 @@ func createEnvironment(t *testing.T, client *Client) (*Environment, func()) {
4444
}
4545
}
4646

47-
func createAgentPool(t *testing.T, client *Client, vcsEnabled bool) (*AgentPool, func()) {
47+
func createAgentPool(t *testing.T, client *Client) (*AgentPool, func()) {
4848
ctx := context.Background()
4949
ap, err := client.AgentPools.Create(ctx, AgentPoolCreateOptions{
50-
Name: String("provider-tst-pool-" + randomString(t)),
51-
Account: &Account{ID: defaultAccountID},
52-
VcsEnabled: Bool(vcsEnabled),
50+
Name: String("provider-tst-pool-" + randomString(t)),
51+
Account: &Account{ID: defaultAccountID},
5352
})
5453
if err != nil {
5554
t.Fatal(err)

run_triggers_test.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,14 @@ func TestRunTriggersRead(t *testing.T) {
8888
Downstream: &Downstream{ID: wsTest1.ID},
8989
Upstream: &Upstream{ID: wsTest2.ID},
9090
}
91-
createdTrigger, err := client.RunTriggers.Create(ctx, options)
91+
created_trigger, err := client.RunTriggers.Create(ctx, options)
9292
require.NoError(t, err)
93-
assert.NotEmpty(t, createdTrigger.ID)
93+
assert.NotEmpty(t, created_trigger.ID)
9494

9595
t.Run("get run trigger by id", func(t *testing.T) {
96-
trigger, err := client.RunTriggers.Read(ctx, createdTrigger.ID)
96+
trigger, err := client.RunTriggers.Read(ctx, created_trigger.ID)
9797
require.NoError(t, err)
98-
assert.Equal(t, createdTrigger.ID, trigger.ID)
99-
assert.Equal(t, createdTrigger.Upstream.ID, trigger.Upstream.ID)
100-
assert.Equal(t, createdTrigger.Downstream.ID, trigger.Downstream.ID)
98+
assert.Equal(t, created_trigger, trigger)
10199
})
102100

103101
t.Run("try to get run trigger with not valid ID", func(t *testing.T) {

vcs_provider.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ type VcsProvider struct {
7575
// Relations
7676
Environments []*Environment `jsonapi:"relation,environments"`
7777
Account *Account `jsonapi:"relation,account"`
78-
AgentPool *AgentPool `jsonapi:"relation,agent-pool"`
7978
}
8079

8180
// VcsProvidersListOptions represents the options for listing vcs providers.
@@ -97,7 +96,6 @@ type VcsProvidersListOptions struct {
9796
// Scope filters.
9897
Environment *string `url:"filter[environment],omitempty"`
9998
Account *string `url:"filter[account],omitempty"`
100-
AgentPool *string `url:"filter[agent-pool],omitempty"`
10199
}
102100

103101
// List the vcs providers.
@@ -130,7 +128,6 @@ type VcsProviderCreateOptions struct {
130128
// Relations
131129
Environments []*Environment `jsonapi:"relation,environments,omitempty"`
132130
Account *Account `jsonapi:"relation,account,omitempty"`
133-
AgentPool *AgentPool `jsonapi:"relation,agent-pool,omitempty"`
134131
}
135132

136133
// Create is used to create a new vcs provider.
@@ -181,9 +178,6 @@ type VcsProviderUpdateOptions struct {
181178
Token *string `jsonapi:"attr,token,omitempty"`
182179
Url *string `jsonapi:"attr,url,omitempty"`
183180
Username *string `jsonapi:"attr,username,omitempty"`
184-
185-
// Relations
186-
AgentPool *AgentPool `jsonapi:"relation,agent-pool"`
187181
}
188182

189183
// Update settings of an existing vcs provider.

vcs_provider_test.go

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func TestVcsProvidersCreate(t *testing.T) {
6868

6969
t.Run("with valid options", func(t *testing.T) {
7070
options := VcsProviderCreateOptions{
71-
Name: String("vcs-" + randomString(t)),
71+
Name: String("foo"),
7272
VcsType: Github,
7373
AuthType: PersonalToken,
7474
Token: os.Getenv("GITHUB_TOKEN"),
@@ -95,25 +95,6 @@ func TestVcsProvidersCreate(t *testing.T) {
9595
}
9696
})
9797

98-
t.Run("with agent-pool attr vcs-enabled: false", func(t *testing.T) {
99-
ap, apCleanup := createAgentPool(t, client, false)
100-
defer apCleanup()
101-
102-
options := VcsProviderCreateOptions{
103-
Name: String("vcs-" + randomString(t)),
104-
VcsType: Github,
105-
AuthType: PersonalToken,
106-
Token: os.Getenv("GITHUB_TOKEN"),
107-
108-
Environments: []*Environment{envTest},
109-
Account: &Account{ID: defaultAccountID},
110-
AgentPool: ap,
111-
}
112-
113-
_, err := client.VcsProviders.Create(ctx, options)
114-
require.Error(t, err)
115-
})
116-
11798
t.Run("when options has an invalid environment", func(t *testing.T) {
11899
_, err := client.VcsProviders.Create(ctx, VcsProviderCreateOptions{
119100
Name: String("test-vcs"),

workspace_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func TestWorkspacesCreate(t *testing.T) {
7474
envTest, envTestCleanup := createEnvironment(t, client)
7575
defer envTestCleanup()
7676

77-
pool, poolCleanup := createAgentPool(t, client, false)
77+
pool, poolCleanup := createAgentPool(t, client)
7878
defer poolCleanup()
7979

8080
t.Run("with valid options", func(t *testing.T) {
@@ -272,7 +272,7 @@ func TestWorkspacesUpdate(t *testing.T) {
272272
envTest, envTestCleanup := createEnvironment(t, client)
273273
defer envTestCleanup()
274274

275-
pool, poolCleanup := createAgentPool(t, client, false)
275+
pool, poolCleanup := createAgentPool(t, client)
276276
defer poolCleanup()
277277

278278
wsTest, _ := createWorkspace(t, client, envTest)

0 commit comments

Comments
 (0)