/
purge_expired_certs.go
45 lines (38 loc) · 1.23 KB
/
purge_expired_certs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
Copyright 2020 The Magma Authors.
This source code is licensed under the BSD-style license found in the
LICENSE file in the root directory of this source tree.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Package handlers implements individual accessc commands as well as common
// across multiple commands functionality
package handlers
import (
"fmt"
"log"
"os"
"github.com/go-magma/magma/orc8r/cloud/go/services/certifier"
"github.com/go-magma/magma/orc8r/cloud/go/tools/commands"
)
// List-certs command - prints out all registered certificates & associated with
// them Identities
func init() {
cmd := CommandRegistry.Add(
"collect-garbage",
"Remove all expired certificates",
collectGarbage)
cmd.Flags().Usage = func() {
fmt.Printf("\tUsage: %s %s\n", os.Args[0], cmd.Name())
}
}
func collectGarbage(cmd *commands.Command, args []string) int {
err := certifier.CollectGarbage()
if err != nil {
log.Fatalf("Garbage Collection Error: %s", err)
}
return 0
}