@@ -10,11 +10,11 @@ import (
1010 "github.com/jackc/pgx/v5"
1111)
1212
13- const rCertPath = "/data/.registration"
13+ const registrationFile = "/data/.registration"
1414
1515func isRegistered (ctx context.Context , conn * pgx.Conn , n * Node ) (bool , error ) {
1616 // Short-circuit if we are holding a certificate
17- if hasRegistrationCertificate () {
17+ if registrationCertExists () {
1818 return true , nil
1919 }
2020
@@ -52,7 +52,7 @@ func isRegistered(ctx context.Context, conn *pgx.Conn, n *Node) (bool, error) {
5252
5353 // If we are active, issue registration certificate
5454 if member .Active {
55- if err := issueRegistrationCertificate (); err != nil {
55+ if err := issueRegistrationCert (); err != nil {
5656 fmt .Println ("failed to issue registration certificate." )
5757 return true , nil
5858 }
@@ -61,15 +61,19 @@ func isRegistered(ctx context.Context, conn *pgx.Conn, n *Node) (bool, error) {
6161 return true , nil
6262}
6363
64- func issueRegistrationCertificate () error {
65- return os .WriteFile (rCertPath , []byte ("" ), 0600 )
64+ func issueRegistrationCert () error {
65+ return os .WriteFile (registrationFile , []byte ("" ), 0600 )
6666}
6767
68- func hasRegistrationCertificate () bool {
69- if _ , err := os .Stat (rCertPath ); err != nil {
68+ func registrationCertExists () bool {
69+ if _ , err := os .Stat (registrationFile ); err != nil {
7070 if os .IsNotExist (err ) {
7171 return false
7272 }
7373 }
7474 return true
7575}
76+
77+ func removeRegistrationCert () error {
78+ return os .Remove (registrationFile )
79+ }
0 commit comments