@@ -10,11 +10,11 @@ import (
10
10
"github.com/jackc/pgx/v5"
11
11
)
12
12
13
- const rCertPath = "/data/.registration"
13
+ const registrationFile = "/data/.registration"
14
14
15
15
func isRegistered (ctx context.Context , conn * pgx.Conn , n * Node ) (bool , error ) {
16
16
// Short-circuit if we are holding a certificate
17
- if hasRegistrationCertificate () {
17
+ if registrationCertExists () {
18
18
return true , nil
19
19
}
20
20
@@ -52,7 +52,7 @@ func isRegistered(ctx context.Context, conn *pgx.Conn, n *Node) (bool, error) {
52
52
53
53
// If we are active, issue registration certificate
54
54
if member .Active {
55
- if err := issueRegistrationCertificate (); err != nil {
55
+ if err := issueRegistrationCert (); err != nil {
56
56
fmt .Println ("failed to issue registration certificate." )
57
57
return true , nil
58
58
}
@@ -61,15 +61,19 @@ func isRegistered(ctx context.Context, conn *pgx.Conn, n *Node) (bool, error) {
61
61
return true , nil
62
62
}
63
63
64
- func issueRegistrationCertificate () error {
65
- return os .WriteFile (rCertPath , []byte ("" ), 0600 )
64
+ func issueRegistrationCert () error {
65
+ return os .WriteFile (registrationFile , []byte ("" ), 0600 )
66
66
}
67
67
68
- func hasRegistrationCertificate () bool {
69
- if _ , err := os .Stat (rCertPath ); err != nil {
68
+ func registrationCertExists () bool {
69
+ if _ , err := os .Stat (registrationFile ); err != nil {
70
70
if os .IsNotExist (err ) {
71
71
return false
72
72
}
73
73
}
74
74
return true
75
75
}
76
+
77
+ func removeRegistrationCert () error {
78
+ return os .Remove (registrationFile )
79
+ }
0 commit comments