Skip to content

Commit cf7eb6b

Browse files
eac auto register support for gitlab enterprise (#134)
1 parent efa0f00 commit cf7eb6b

File tree

4 files changed

+60
-45
lines changed

4 files changed

+60
-45
lines changed

client/models.go

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -75,42 +75,46 @@ type AgentSpaceAssociation struct {
7575
}
7676

7777
type RepoSpaceAssociation struct {
78-
URL string `json:"repository_url"`
79-
AccessToken *string `json:"access_token"`
80-
Type string `json:"repository_type"`
81-
Branch string `json:"branch"`
82-
Name string `json:"repository_name"`
78+
URL string `json:"repository_url"`
79+
AccessToken *string `json:"access_token"`
80+
Type string `json:"repository_type"`
81+
Branch string `json:"branch"`
82+
Name string `json:"repository_name"`
83+
AutoRegisterEac bool `json:"eac_auto_registration"`
8384
}
8485

8586
type RepoSpaceAssociationWithCredentials struct {
86-
URL string `json:"repository_url"`
87-
Token *string `json:"token"`
88-
Type string `json:"repository_type"`
89-
Branch string `json:"branch"`
90-
Name string `json:"repository_name"`
91-
CredentialName *string `json:"credential_name"`
87+
URL string `json:"repository_url"`
88+
Token *string `json:"token"`
89+
Type string `json:"repository_type"`
90+
Branch string `json:"branch"`
91+
Name string `json:"repository_name"`
92+
CredentialName *string `json:"credential_name"`
93+
AutoRegisterEac bool `json:"eac_auto_registration"`
9294
}
9395

9496
type GitlabEnterpriseRepoSpaceAssociation struct {
95-
Name string `json:"repository_name"`
96-
URL string `json:"repository_url"`
97-
Token *string `json:"token"`
98-
Branch string `json:"branch"`
99-
CredentialName string `json:"credential_name"`
100-
UseAllAgents bool `json:"use_all_agents"`
101-
Agents []string `json:"agents"`
97+
Name string `json:"repository_name"`
98+
URL string `json:"repository_url"`
99+
Token *string `json:"token"`
100+
Branch string `json:"branch"`
101+
CredentialName string `json:"credential_name"`
102+
UseAllAgents bool `json:"use_all_agents"`
103+
Agents []string `json:"agents"`
104+
AutoRegisterEac bool `json:"eac_auto_registration"`
102105
}
103106

104107
type CodeCommitRepoSpaceAssociation struct {
105-
URL string `json:"repository_url"`
106-
RoleArn string `json:"role_arn"`
107-
Region string `json:"region"`
108-
Branch string `json:"branch"`
109-
Name string `json:"repository_name"`
110-
ExternalId string `json:"external_id"`
111-
Username string `json:"username"`
112-
Password string `json:"password"`
113-
CredentialName string `json:"credential_name"`
108+
URL string `json:"repository_url"`
109+
RoleArn string `json:"role_arn"`
110+
Region string `json:"region"`
111+
Branch string `json:"branch"`
112+
Name string `json:"repository_name"`
113+
ExternalId string `json:"external_id"`
114+
Username string `json:"username"`
115+
Password string `json:"password"`
116+
CredentialName string `json:"credential_name"`
117+
AutoRegisterEac bool `json:"eac_auto_registration"`
114118
}
115119

116120
type KeyValuePair struct {

client/repository.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,20 @@ func (c *Client) OnboardCodeCommitRepoToSpace(space_name string, repository_name
4444
return nil
4545
}
4646

47-
func (c *Client) OnboardGitlabEnterpriseRepoToSpace(space_name string, repository_name string, repository_url string, token *string, branch string, credential_name string, agents []string, use_all_agents bool) error {
47+
func (c *Client) OnboardGitlabEnterpriseRepoToSpace(space_name string, repository_name string, repository_url string, token *string, branch string, credential_name string, agents []string, use_all_agents bool, auto_register_eac bool) error {
4848
data := GitlabEnterpriseRepoSpaceAssociation{
49-
Token: token,
50-
Name: repository_name,
51-
URL: repository_url,
52-
Branch: branch,
53-
CredentialName: credential_name,
54-
Agents: agents,
55-
UseAllAgents: use_all_agents,
49+
Token: token,
50+
Name: repository_name,
51+
URL: repository_url,
52+
Branch: branch,
53+
CredentialName: credential_name,
54+
Agents: agents,
55+
UseAllAgents: use_all_agents,
56+
AutoRegisterEac: auto_register_eac,
5657
}
5758

5859
payload, err := json.Marshal(data)
60+
5961
if err != nil {
6062
log.Fatalf("impossible to marshall agent association: %s", err)
6163
}

docs/resources/gitlab_enterprise_repository_space_association.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ resource "torque_gitlab_enterprise_repository_space_association" "repository" {
5454
### Optional
5555

5656
- `agents` (List of String) List of specific agents to use to onboard and sync this repository. Cannot be specified when use_all_agents is true.
57+
- `auto_register_eac` (Boolean) Auto register environment files
5758
- `timeout` (Number) Time in minutes to wait for Torque to sync the repository during the onboarding. Default is 1 minute.
5859
- `token` (String, Deprecated) Authentication Token to the project/repository. If omitted, existing credentials provided in the credential_name field will be used for authentication. If provided, a new credentials object will be created.
5960
- `use_all_agents` (Boolean) Whether all associated agents can be used to onboard and sync this repository. Must be set to false if agents attribute is used.

internal/provider/resources/space_gitlab_enterprise_repository_resource.go

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@ type TorqueSpaceGitlabEnterpriseRepositoryResource struct {
3232
}
3333

3434
type TorqueSpaceGitlabEnterpriseRepositoryResourceModel struct {
35-
SpaceName types.String `tfsdk:"space_name"`
36-
RepositoryName types.String `tfsdk:"repository_name"`
37-
RepositoryUrl types.String `tfsdk:"repository_url"`
38-
Token types.String `tfsdk:"token"`
39-
Branch types.String `tfsdk:"branch"`
40-
CredentialName types.String `tfsdk:"credential_name"`
41-
UseAllAgents types.Bool `tfsdk:"use_all_agents"`
42-
Agents types.List `tfsdk:"agents"`
43-
TimeOut types.Int32 `tfsdk:"timeout"`
35+
SpaceName types.String `tfsdk:"space_name"`
36+
RepositoryName types.String `tfsdk:"repository_name"`
37+
RepositoryUrl types.String `tfsdk:"repository_url"`
38+
Token types.String `tfsdk:"token"`
39+
Branch types.String `tfsdk:"branch"`
40+
CredentialName types.String `tfsdk:"credential_name"`
41+
UseAllAgents types.Bool `tfsdk:"use_all_agents"`
42+
Agents types.List `tfsdk:"agents"`
43+
TimeOut types.Int32 `tfsdk:"timeout"`
44+
AutoRegisterEac types.Bool `tfsdk:"auto_register_eac"`
4445
}
4546

4647
func (r *TorqueSpaceGitlabEnterpriseRepositoryResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
@@ -112,6 +113,13 @@ func (r *TorqueSpaceGitlabEnterpriseRepositoryResource) Schema(ctx context.Conte
112113
Computed: true,
113114
Default: int32default.StaticInt32(1),
114115
},
116+
"auto_register_eac": schema.BoolAttribute{
117+
Description: "Auto register environment files",
118+
Default: booldefault.StaticBool(false),
119+
Required: false,
120+
Optional: true,
121+
Computed: true,
122+
},
115123
},
116124
}
117125
}
@@ -156,7 +164,7 @@ func (r *TorqueSpaceGitlabEnterpriseRepositoryResource) Create(ctx context.Conte
156164
}
157165
start := time.Now()
158166
err := r.client.OnboardGitlabEnterpriseRepoToSpace(data.SpaceName.ValueString(), data.RepositoryName.ValueString(),
159-
data.RepositoryUrl.ValueString(), data.Token.ValueStringPointer(), data.Branch.ValueString(), data.CredentialName.ValueString(), agents, data.UseAllAgents.ValueBool())
167+
data.RepositoryUrl.ValueString(), data.Token.ValueStringPointer(), data.Branch.ValueString(), data.CredentialName.ValueString(), agents, data.UseAllAgents.ValueBool(), data.AutoRegisterEac.ValueBool())
160168
if err != nil {
161169
repo, err := r.client.GetRepoDetails(data.SpaceName.ValueString(), data.RepositoryName.ValueString())
162170
if repo == nil {

0 commit comments

Comments
 (0)