Skip to content

Commit 8c9f563

Browse files
feat: 支持模板输出 password
- 在 UserOutput 中添加 Password 字段 - 在 ProcessUserCreation 中保存密码到输出 - 更新模板示例,添加 password 输出示例 - 测试验证:password 成功输出到 YAML 和模板
1 parent 34a4db9 commit 8c9f563

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

examples/template-example.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# GitLab CLI 输出模板示例
22
# 支持 Go template 语法,可以访问 OutputConfig 结构中的所有数据
33
# 数据结构: .Endpoint (完整 URL), .Scheme (http/https), .Host (主机名) 是 GitLab 服务器配置
4-
# 数据结构: .Users[0] 包含 Username, Email, Name, UserID, Token, Groups
4+
# 数据结构: .Users[0] 包含 Username, Email, Name, UserID, Password, Token, Groups, Projects
55

66
{{- range .Users }}
77
# ========================================
@@ -19,6 +19,10 @@ toolchains:
1919
username: {{ .Username }}
2020
# email
2121
email: {{ .Email }}
22+
{{- if .Password }}
23+
# password
24+
password: {{ .Password }}
25+
{{- end }}
2226
{{- if .Token }}
2327
# Personal Access Token
2428
token:

internal/processor/processor.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func (p *ResourceProcessor) ProcessUserCreation(userSpec types.UserSpec) (*types
4848
Username: actualUsername,
4949
Email: actualEmail,
5050
Name: userSpec.Name,
51+
Password: userSpec.Password, // 保存密码到输出
5152
}
5253

5354
// 1. 创建或获取用户

pkg/types/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ type UserOutput struct {
5959
Email string `yaml:"email"`
6060
Name string `yaml:"name"`
6161
UserID int `yaml:"user_id"`
62+
Password string `yaml:"password,omitempty"` // 用户密码
6263
Token *TokenOutput `yaml:"token,omitempty"`
6364
Groups []GroupOutput `yaml:"groups,omitempty"`
6465
Projects []ProjectOutput `yaml:"projects,omitempty"` // 用户级别的项目

0 commit comments

Comments
 (0)