in internal/provider/datasource_gitlab_project_environments.go [70:174]
func (d *gitLabProjectEnvironmentsDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
allowedStatesValues := []string{"available", "stopping", "stopped"}
environmentTiers := []string{"production", "staging", "testing", "development", "other"}
resp.Schema = schema.Schema{
MarkdownDescription: `The ` + "`gitlab_project_environments`" + ` data source retrieves information about all environments of the given project.
**Upstream API**: [GitLab REST API docs](https://docs.gitlab.com/api/environments/#list-environments)`,
Attributes: map[string]schema.Attribute{
"id": schema.StringAttribute{
MarkdownDescription: "The ID of this Terraform resource.",
Computed: true,
},
"project": schema.StringAttribute{
MarkdownDescription: "The ID or full path of the project.",
Required: true,
},
"name": schema.StringAttribute{
MarkdownDescription: "Return the environment with this name. Mutually exclusive with search.",
Optional: true,
Validators: []validator.String{
stringvalidator.ConflictsWith(path.MatchRoot("search")),
},
},
"search": schema.StringAttribute{
MarkdownDescription: "Return list of environments matching the search criteria. Mutually exclusive with name. Must be at least 3 characters long. ",
Optional: true,
Validators: []validator.String{
stringvalidator.ConflictsWith(path.MatchRoot("name")),
},
},
"states": schema.StringAttribute{
MarkdownDescription: fmt.Sprintf("List all environments that match the specified state. Valid values are %s. Returns all environments if not set.", utils.RenderValueListForDocs(allowedStatesValues)),
Optional: true,
Validators: []validator.String{stringvalidator.OneOf(allowedStatesValues...)},
},
"environments": schema.ListNestedAttribute{
MarkdownDescription: "The list of environments.",
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"id": schema.Int64Attribute{
MarkdownDescription: "The ID of the environment.",
Computed: true,
},
"name": schema.StringAttribute{
MarkdownDescription: "The name of the environment.",
Computed: true,
},
// see https://docs.gitlab.com/ci/variables/predefined_variables/, CI_ENVIRONMENT_SLUG. API also truncates and adds a randum suffix.
"slug": schema.StringAttribute{
MarkdownDescription: "The simplified version of the environment name, suitable for inclusion in DNS, URLs, Kubernetes labels, and so on. The slug is truncated to 24 characters. A random suffix is automatically added to uppercase environment names.",
Computed: true,
},
"description": schema.StringAttribute{
MarkdownDescription: "The description of the environment.",
Computed: true,
},
"state": schema.StringAttribute{
MarkdownDescription: fmt.Sprintf("The state of the environment. Value can be one of %s. Returns all environments if not set.", utils.RenderValueListForDocs(allowedStatesValues)),
Computed: true,
},
"tier": schema.StringAttribute{
MarkdownDescription: fmt.Sprintf("The tier of the environment. Value can be one of %s. Returns all environments if not set.", utils.RenderValueListForDocs(environmentTiers)),
Computed: true,
},
"external_url": schema.StringAttribute{
MarkdownDescription: "Place to link to for this environment.",
Computed: true,
},
"created_at": schema.StringAttribute{
MarkdownDescription: "Timestamp of the environment creation, RFC3339 format.",
Computed: true,
},
"updated_at": schema.StringAttribute{
MarkdownDescription: "Timestamp of the last environment update, RFC3339 format.",
Computed: true,
},
"cluster_agent_id": schema.Int64Attribute{
MarkdownDescription: "The ID of the environments cluster agent or `null` if none is assigned.",
Computed: true,
},
"kubernetes_namespace": schema.StringAttribute{
MarkdownDescription: "The Kubernetes namespace to associate with this environment.",
Computed: true,
},
"flux_resource_path": schema.StringAttribute{
MarkdownDescription: "The Flux resource path to associate with this environment.",
Computed: true,
},
"auto_stop_at": schema.StringAttribute{
MarkdownDescription: "Timestamp of when the environment is scheduled to stop, RFC3339 format.",
Computed: true,
},
"auto_stop_setting": schema.StringAttribute{
MarkdownDescription: "The auto stop setting for the environment.",
Computed: true,
},
},
},
},
},
}
}