You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# generated by https://github.com/hashicorp/terraform-plugin-docs
3
+
page_title: "gitlab_repository_file Data Source - terraform-provider-gitlab"
4
+
subcategory: ""
5
+
description: |-
6
+
The gitlab_repository_file data source allows details of a file in a repository to be retrieved.
7
+
Upstream API: GitLab REST API docs https://docs.gitlab.com/ee/api/repository_files.html
8
+
---
9
+
10
+
# gitlab_repository_file (Data Source)
11
+
12
+
The `gitlab_repository_file` data source allows details of a file in a repository to be retrieved.
13
+
14
+
**Upstream API**: [GitLab REST API docs](https://docs.gitlab.com/ee/api/repository_files.html)
15
+
16
+
## Example Usage
17
+
18
+
```terraform
19
+
data "gitlab_repository_file" "example" {
20
+
project = "example"
21
+
ref = "main"
22
+
file_path = "README.md"
23
+
}
24
+
```
25
+
26
+
<!-- schema generated by tfplugindocs -->
27
+
## Schema
28
+
29
+
### Required
30
+
31
+
-**file_path** (String) The full path of the file. It must be relative to the root of the project without a leading slash `/`.
32
+
-**project** (String) The name or ID of the project.
33
+
-**ref** (String) The name of branch, tag or commit.
34
+
35
+
### Optional
36
+
37
+
-**id** (String) The ID of this resource.
38
+
39
+
### Read-Only
40
+
41
+
-**blob_id** (String) The blob id.
42
+
-**commit_id** (String) The commit id.
43
+
-**content** (String) base64 encoded file content. No other encoding is currently supported, because of a [GitLab API bug](https://gitlab.com/gitlab-org/gitlab/-/issues/342430).
-**content** (String) base64 encoded file content. No other encoding is currently supported, because of a [GitLab API bug](https://gitlab.com/gitlab-org/gitlab/-/issues/342430).
51
51
-**file_path** (String) The full path of the file. It must be relative to the root of the project without a leading slash `/`.
52
-
-**project** (String) The ID of the project.
52
+
-**project** (String) The name or ID of the project.
// However, we don't support the `encoding` parameter as it seems to be broken.
35
35
// Only a value of `base64` is supported, all others, including the documented default `text`, lead to
36
36
// a `400 {error: encoding does not have a valid value}` error.
37
-
Schema: map[string]*schema.Schema{
38
-
"project": {
39
-
Description: "The ID of the project.",
40
-
Type: schema.TypeString,
41
-
Required: true,
42
-
ForceNew: true,
37
+
Schema: constructSchema(
38
+
map[string]*schema.Schema{
39
+
"branch": {
40
+
Description: "Name of the branch to which to commit to.",
41
+
Type: schema.TypeString,
42
+
Required: true,
43
+
ForceNew: true,
44
+
},
45
+
"start_branch": {
46
+
Description: "Name of the branch to start the new commit from.",
47
+
Type: schema.TypeString,
48
+
Optional: true,
49
+
},
50
+
"author_email": {
51
+
Description: "Email of the commit author.",
52
+
Type: schema.TypeString,
53
+
Optional: true,
54
+
},
55
+
"author_name": {
56
+
Description: "Name of the commit author.",
57
+
Type: schema.TypeString,
58
+
Optional: true,
59
+
},
60
+
"commit_message": {
61
+
Description: "Commit message.",
62
+
Type: schema.TypeString,
63
+
Required: true,
64
+
},
43
65
},
44
-
"file_path": {
45
-
Description: "The full path of the file. It must be relative to the root of the project without a leading slash `/`.",
46
-
Type: schema.TypeString,
47
-
Required: true,
48
-
ForceNew: true,
49
-
},
50
-
"branch": {
51
-
Description: "Name of the branch to which to commit to.",
52
-
Type: schema.TypeString,
53
-
Required: true,
54
-
ForceNew: true,
55
-
},
56
-
"start_branch": {
57
-
Description: "Name of the branch to start the new commit from.",
58
-
Type: schema.TypeString,
59
-
Optional: true,
60
-
},
61
-
"author_email": {
62
-
Description: "Email of the commit author.",
63
-
Type: schema.TypeString,
64
-
Optional: true,
65
-
},
66
-
"author_name": {
67
-
Description: "Name of the commit author.",
68
-
Type: schema.TypeString,
69
-
Optional: true,
70
-
},
71
-
"content": {
72
-
Description: "base64 encoded file content. No other encoding is currently supported, because of a [GitLab API bug](https://gitlab.com/gitlab-org/gitlab/-/issues/342430).",
73
-
Type: schema.TypeString,
74
-
Required: true,
75
-
ValidateFunc: validateBase64Content,
76
-
},
77
-
"commit_message": {
78
-
Description: "Commit message.",
79
-
Type: schema.TypeString,
80
-
Required: true,
81
-
},
82
-
"encoding": {
83
-
Description: "Content encoding.",
84
-
Type: schema.TypeString,
85
-
Computed: true,
86
-
},
87
-
},
66
+
gitlabRepositoryFileGetSchema(),
67
+
),
88
68
}
89
69
})
90
70
@@ -136,11 +116,11 @@ func resourceGitlabRepositoryFileRead(ctx context.Context, d *schema.ResourceDat
Description: "The full path of the file. It must be relative to the root of the project without a leading slash `/`.",
18
+
Type: schema.TypeString,
19
+
Required: true,
20
+
ForceNew: true,
21
+
},
22
+
"ref": {
23
+
Description: "The name of branch, tag or commit.",
24
+
Type: schema.TypeString,
25
+
Computed: true,
26
+
},
27
+
"file_name": {
28
+
Description: "The filename.",
29
+
Type: schema.TypeString,
30
+
Computed: true,
31
+
},
32
+
"size": {
33
+
Description: "The file size.",
34
+
Type: schema.TypeInt,
35
+
Computed: true,
36
+
},
37
+
"encoding": {
38
+
Description: "The file content encoding.",
39
+
Type: schema.TypeString,
40
+
Computed: true,
41
+
},
42
+
"content": {
43
+
Description: "base64 encoded file content. No other encoding is currently supported, because of a [GitLab API bug](https://gitlab.com/gitlab-org/gitlab/-/issues/342430).",
0 commit comments