Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dfss
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mpcs
dfss
Commits
3fa6461a
There was a problem fetching the pipeline summary.
Commit
3fa6461a
authored
8 years ago
by
Loïck Bonniot
Browse files
Options
Downloads
Plain Diff
Merge branch 'unregister-command-does-not-work-22' into 'master'
[c] Fix unregister command Closes
#22
See merge request
!94
parents
9fcd645d
65558011
Branches
master
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!94
[c] Fix unregister command
Pipeline
#
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dfssc/cmd/unregister.go
+3
-2
3 additions, 2 deletions
dfssc/cmd/unregister.go
dfssc/user/unregister.go
+17
-13
17 additions, 13 deletions
dfssc/user/unregister.go
with
20 additions
and
15 deletions
dfssc/cmd/unregister.go
+
3
−
2
View file @
3fa6461a
...
...
@@ -22,14 +22,15 @@ var unregisterCmd = &cobra.Command{
}
// Confirmation
var
ready
string
var
passphrase
,
ready
string
_
=
readPassword
(
&
passphrase
,
false
)
readStringParam
(
"Do you REALLY want to delete "
+
cert
.
Subject
.
CommonName
+
"? Type 'yes' to confirm"
,
""
,
&
ready
)
if
ready
!=
"yes"
{
fmt
.
Fprintln
(
os
.
Stderr
,
"Unregistering aborted!"
)
os
.
Exit
(
1
)
}
err
=
user
.
Unregister
()
err
=
user
.
Unregister
(
passphrase
)
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
"Cannot unregister:"
,
err
.
Error
())
os
.
Exit
(
2
)
...
...
This diff is collapsed.
Click to expand it.
dfssc/user/unregister.go
+
17
−
13
View file @
3fa6461a
package
user
import
(
"
errors
"
pb
"dfss/dfssp/api"
"
dfss/dfssc/common
"
"dfss/dfssc/security"
"dfss/dfssp/api"
"dfss/net"
"github.com/spf13/viper"
"golang.org/x/net/context"
"google.golang.org/grpc"
)
// Unregister a user from the platform
func
Unregister
()
error
{
client
,
err
:=
connect
()
func
Unregister
(
passphrase
string
)
error
{
auth
:=
security
.
NewAuthContainer
(
passphrase
)
ca
,
cert
,
key
,
err
:=
auth
.
LoadFiles
()
if
err
!=
nil
{
return
err
}
conn
,
err
:=
net
.
Connect
(
viper
.
GetString
(
"platform_addrport"
),
cert
,
key
,
ca
,
nil
)
if
err
!=
nil
{
return
err
}
// Stop the context if it takes too long for the platform to answer
client
:=
api
.
NewPlatformClient
(
conn
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
net
.
DefaultTimeout
)
defer
cancel
()
response
,
err
:=
client
.
Unregister
(
ctx
,
&
pb
.
Empty
{})
response
,
err
:=
client
.
Unregister
(
ctx
,
&
api
.
Empty
{})
if
err
!=
nil
{
return
errors
.
New
(
grpc
.
ErrorDesc
(
err
))
}
if
response
.
Code
!=
pb
.
ErrorCode_SUCCESS
{
return
errors
.
New
(
response
.
Message
)
return
err
}
return
nil
return
common
.
EvaluateErrorCodeResponse
(
response
)
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment