Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add coderd_user data source#19

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ethanndickson merged 10 commits intomainfromethan/user-data
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes fromall 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
30 changes: 0 additions & 30 deletionsdocs/data-sources/example.md
View file
Open in desktop

This file was deleted.

33 changes: 33 additions & 0 deletionsdocs/data-sources/user.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "coderd_user Data Source - coderd"
subcategory: ""
description: |-
An existing user on the coder deployment
---

# coderd_user (Data Source)

An existing user on the coder deployment



<!-- schema generated by tfplugindocs -->
## Schema

### Optional

- `id` (String) The ID of the user to retrieve. This field will be populated if a username is supplied.
- `username` (String) The username of the user to retrieve. This field will be populated if an ID is supplied.

### Read-Only

- `created_at` (Number) Unix timestamp of when the user was created.
- `email` (String) Email of the user.
- `last_seen_at` (Number) Unix timestamp of when the user was last seen.
- `login_type` (String) Type of login for the user. Valid types are 'none', 'password', 'github', and 'oidc'.
- `name` (String) Display name of the user. Defaults to username.
- `organization_ids` (Set of String) IDs of organizations the user is associated with.
- `roles` (Set of String) Roles assigned to the user. Valid roles are 'owner', 'template-admin', 'user-admin', and 'auditor'.
- `suspended` (Boolean) Whether the user is suspended.
- `theme_preference` (String) The user's preferred theme.
15 changes: 15 additions & 0 deletionsintegration/integration_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -49,10 +49,24 @@ func TestIntegration(t *testing.T) {

for _, tt := range []struct {
name string
preF func(testing.TB, *codersdk.Client)
assertF func(testing.TB, *codersdk.Client)
}{
{
name: "user-test",
preF: func(t testing.TB, c *codersdk.Client) {
me, err := c.User(ctx, codersdk.Me)
assert.NoError(t, err)
_, err = c.CreateUser(ctx, codersdk.CreateUserRequest{
Email: "test2@coder.com",
Username: "ethan",
Password: "SomeSecurePassword!",
UserLoginType: "password",
DisableLogin: false,
OrganizationID: me.OrganizationIDs[0],
})
assert.NoError(t, err)
},
assertF: func(t testing.TB, c *codersdk.Client) {
// Check user fields.
user, err := c.User(ctx, "dean")
Expand DownExpand Up@@ -102,6 +116,7 @@ func TestIntegration(t *testing.T) {
var buf bytes.Buffer
tfCmd.Stdout = &buf
tfCmd.Stderr = &buf
tt.preF(t, client)
if err := tfCmd.Run(); !assert.NoError(t, err) {
t.Logf(buf.String())
}
Expand Down
14 changes: 14 additions & 0 deletionsintegration/user-test/main.tf
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,3 +16,17 @@ resource "coderd_user" "dean" {
password = "SomeSecurePassword!"
suspended = false
}

data "coderd_user" "ethan" {
username = "ethan"
}

resource "coderd_user" "ethan2" {
username = "${data.coderd_user.ethan.username}2"
name = "${data.coderd_user.ethan.name}2"
email = "${data.coderd_user.ethan.email}.au"
login_type = "${data.coderd_user.ethan.login_type}"
roles = data.coderd_user.ethan.roles
suspended = data.coderd_user.ethan.suspended
}

104 changes: 0 additions & 104 deletionsinternal/provider/example_data_source.go
View file
Open in desktop

This file was deleted.

37 changes: 0 additions & 37 deletionsinternal/provider/example_data_source_test.go
View file
Open in desktop

This file was deleted.

5 changes: 1 addition & 4 deletionsinternal/provider/provider.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package provider

import (
Expand DownExpand Up@@ -112,7 +109,7 @@ func (p *CoderdProvider) Resources(ctx context.Context) []func() resource.Resour

func (p *CoderdProvider) DataSources(ctx context.Context) []func() datasource.DataSource {
return []func() datasource.DataSource{
NewExampleDataSource,
NewUserDataSource,
}
}

Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp