@@ -39,10 +39,17 @@ var (
3939 }
4040)
4141
42- type rancherIPRestriction struct {
43- CIDRBlock string `json:"cidrBlock"`
44- Description string `json:"description"`
45- }
42+ type (
43+ rancherIPRestriction struct {
44+ CIDRBlock string `json:"cidrBlock"`
45+ Description string `json:"description"`
46+ }
47+
48+ rancherUser struct {
49+ Username string `json:"username"`
50+ Password string `json:"password"`
51+ }
52+ )
4653
4754func ListCloudRanchers (_ * cobra.Command , _ []string ) {
4855 projectID , err := getConfiguredCloudProject ()
@@ -119,6 +126,23 @@ func CreateRancher(cmd *cobra.Command, args []string) {
119126 display .OutputInfo (& flags .OutputFormatConfig , rancher , "✅ Rancher %s created successfully (id: %s)" , RancherSpec .TargetSpec .Name , rancher ["id" ])
120127}
121128
129+ func ResetAdminCredentials (_ * cobra.Command , args []string ) {
130+ projectID , err := getConfiguredCloudProject ()
131+ if err != nil {
132+ display .OutputError (& flags .OutputFormatConfig , "%s" , err )
133+ return
134+ }
135+
136+ var user rancherUser
137+ endpoint := fmt .Sprintf ("/v2/publicCloud/project/%s/rancher/%s/adminCredentials" , projectID , url .PathEscape (args [0 ]))
138+ if err := httpLib .Client .Post (endpoint , nil , & user ); err != nil {
139+ display .OutputError (& flags .OutputFormatConfig , "failed to reset admin credentials for Rancher service: %s" , err )
140+ return
141+ }
142+
143+ display .OutputInfo (& flags .OutputFormatConfig , nil , "✅ New Rancher service password for user %s: %s" , user .Username , user .Password )
144+ }
145+
122146func DeleteRancher (_ * cobra.Command , args []string ) {
123147 projectID , err := getConfiguredCloudProject ()
124148 if err != nil {
0 commit comments