Skip to content

Commit 706f2e0

Browse files
committed
MEDIUM: add certificates interface
1 parent 56e4556 commit 706f2e0

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

runtime/interface.go

+8
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,13 @@ type Raw interface {
136136
ExecuteRaw(command string) (string, error)
137137
}
138138

139+
type Cert interface {
140+
NewCertEntry(filename string) error
141+
SetCertEntry(filename, payload string) error
142+
CommitCertEntry(filename string) error
143+
AddCrtListEntry(crtList string, entry CrtListEntry) error
144+
}
145+
139146
type Runtime interface {
140147
Info
141148
Frontend
@@ -145,6 +152,7 @@ type Runtime interface {
145152
ACLs
146153
Tables
147154
Raw
155+
Cert
148156
SocketPath() string
149157
IsStatsSocket() bool
150158
}

runtime/runtime_client.go

+45
Original file line numberDiff line numberDiff line change
@@ -979,3 +979,48 @@ func (c *client) SocketPath() string {
979979
func (c *client) IsStatsSocket() bool {
980980
return !c.runtime.masterWorkerMode
981981
}
982+
983+
func (c *client) NewCertEntry(filename string) error {
984+
if !c.runtime.IsValid() {
985+
return errors.New("no valid runtime found")
986+
}
987+
if err := c.runtime.NewCertEntry(filename); err != nil {
988+
return fmt.Errorf("%s %w", c.runtime.socketPath, err)
989+
}
990+
991+
return nil
992+
}
993+
994+
func (c *client) SetCertEntry(filename string, payload string) error {
995+
if !c.runtime.IsValid() {
996+
return errors.New("no valid runtime found")
997+
}
998+
if err := c.runtime.SetCertEntry(filename, payload); err != nil {
999+
return fmt.Errorf("%s %w", c.runtime.socketPath, err)
1000+
}
1001+
1002+
return nil
1003+
}
1004+
1005+
func (c *client) CommitCertEntry(filename string) error {
1006+
if !c.runtime.IsValid() {
1007+
return errors.New("no valid runtime found")
1008+
}
1009+
if err := c.runtime.CommitCertEntry(filename); err != nil {
1010+
return fmt.Errorf("%s %w", c.runtime.socketPath, err)
1011+
}
1012+
1013+
return nil
1014+
}
1015+
1016+
func (c *client) AddCrtListEntry(crtList string, entry CrtListEntry) error {
1017+
if !c.runtime.IsValid() {
1018+
return errors.New("no valid runtime found")
1019+
}
1020+
1021+
if err := c.runtime.AddCrtListEntry(crtList, entry); err != nil {
1022+
return fmt.Errorf("%s %w", c.runtime.socketPath, err)
1023+
}
1024+
1025+
return nil
1026+
}

0 commit comments

Comments
 (0)