Skip to content

Commit

Permalink
agent-config: generate and use attestation-agent toml
Browse files Browse the repository at this point in the history
Generate the attestation-agent toml file aa.toml when aaKBCParams provided
Use the cfg file to start attestation agent service when it exists
Start attestation agent service directly when no cfg file exists

Signed-off-by: Qi Feng Huo <huoqif@cn.ibm.com>
  • Loading branch information
Qi Feng Huo committed Jun 20, 2024
1 parent c51f3d7 commit 09fae96
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/cloud-api-adaptor/pkg/adaptor/cloud/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ func (s *cloudService) CreateVM(ctx context.Context, req *pb.CreateVMRequest) (r
Content: toml,
})

toml, err = agent.CreateConfigFile(s.aaKBCParams, "")
toml, err = agent.CreateConfigFile(s.aaKBCParams)
if err != nil {
return nil, fmt.Errorf("creating attestation agent config: %w", err)
}
Expand Down
4 changes: 1 addition & 3 deletions src/cloud-api-adaptor/pkg/agent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ type TokenConfigs struct {
} `toml:"token_configs.coco_as"`
Kbs struct {
URL string `toml:"url"`
Cert string `toml:"cert"`
} `toml:"token_configs.kbs"`
}

Expand All @@ -31,7 +30,7 @@ func parseAAKBCParams(aaKBCParams string) (string, error) {
return url, nil
}

func CreateConfigFile(aaKBCParams string, certStr string) (string, error) {
func CreateConfigFile(aaKBCParams string) (string, error) {
url, err := parseAAKBCParams(aaKBCParams)
if err != nil {
return "", err
Expand All @@ -40,7 +39,6 @@ func CreateConfigFile(aaKBCParams string, certStr string) (string, error) {
config := TokenConfigs{}
config.CocoAs.URL = ""
config.Kbs.URL = url
config.Kbs.Cert = certStr

bytes, err := toml.Marshal(config)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions src/cloud-api-adaptor/pkg/agent/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ url = ''
[token_configs.kbs]
url = 'http://127.0.0.1:8080'
cert = ''
`

config, err := CreateConfigFile("cc_kbc::http://127.0.0.1:8080", "")
config, err := CreateConfigFile("cc_kbc::http://127.0.0.1:8080")
if err != nil {
t.Error(err)
}
Expand Down

0 comments on commit 09fae96

Please sign in to comment.