Skip to content

Commit

Permalink
agent-config: generate agent-config and fix lint err
Browse files Browse the repository at this point in the history
- Create agent config toml Like CDH when createVM instance

Signed-off-by: Qi Feng Huo <huoqif@cn.ibm.com>
  • Loading branch information
Qi Feng Huo committed Jun 18, 2024
1 parent dab08aa commit 321b2a1
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 12 deletions.
5 changes: 2 additions & 3 deletions src/cloud-api-adaptor/cmd/process-user-data/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"os"

cmdUtil "github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/cmd"
"github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/pkg/agent"
"github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/pkg/cdh"
daemon "github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/pkg/forwarder"
"github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/pkg/userdata"
Expand All @@ -19,7 +18,7 @@ const (
providerAzure = "azure"
providerAws = "aws"

defaultAuthJsonPath = "/run/peerpod/auth.json"
defaultAuthJsonPath = "/run/peerpod/auth.json"
)

var versionFlag bool
Expand All @@ -36,7 +35,7 @@ var rootCmd = &cobra.Command{
}

func init() {
var agentConfigPath, cdhConfigPath, daemonConfigPath string
var cdhConfigPath, daemonConfigPath string
var fetchTimeout int

rootCmd.PersistentFlags().BoolVarP(&versionFlag, "version", "v", false, "Print the version")
Expand Down
1 change: 0 additions & 1 deletion src/cloud-api-adaptor/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ require (
github.com/pelletier/go-toml/v2 v2.1.0
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.7.0
github.com/tj/assert v0.0.3
golang.org/x/crypto v0.22.0
golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2
google.golang.org/protobuf v1.33.0
Expand Down
2 changes: 0 additions & 2 deletions src/cloud-api-adaptor/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,6 @@ github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 h1:kdXcSzyDtse
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/tj/assert v0.0.3 h1:Df/BlaZ20mq6kuai7f5z2TvPFiwC3xaWJSDQNiIS3Rk=
github.com/tj/assert v0.0.3/go.mod h1:Ne6X72Q+TB1AteidzQncjw9PabbMp4PBMZ1k+vd1Pvk=
github.com/vishvananda/netlink v1.2.1-beta.2 h1:Llsql0lnQEbHj0I1OuKyp8otXp0r3q0mPkuhwHfStVs=
github.com/vishvananda/netlink v1.2.1-beta.2/go.mod h1:twkDnbuQxJYemMlGd4JFIcuhgX83tXhKS2B/PRMpOho=
github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
Expand Down
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 @@ -288,7 +288,7 @@ func (s *cloudService) CreateVM(ctx context.Context, req *pb.CreateVMRequest) (r
Content: toml,
})
}
toml, err := agent.CreateConfigFile(daemonConfig.AAKBCParams);
toml, err := agent.CreateConfigFile(daemonConfig.AAKBCParams)
if err == nil {
cloudConfig.WriteFiles = append(cloudConfig.WriteFiles, cloudinit.WriteFile{
Path: agent.DefaultAgentConfigPath,
Expand Down
10 changes: 5 additions & 5 deletions src/cloud-api-adaptor/pkg/agent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ type AgentConfig struct {
}

func CreateConfigFile(aaKBCParams string) (string, error) {
config := AgentConfig {
ServerAddr: ServerAddr,
AaKbcParams: aaKBCParams,
config := AgentConfig{
ServerAddr: ServerAddr,
AaKbcParams: aaKBCParams,
ImageRegistryAuthFile: DefaultAuthJsonPath,
GuestComponentsProcs: GuestComponentsProcs,
GuestComponentsProcs: GuestComponentsProcs,
}
bytes, err := toml.Marshal(config)
if err != nil {
return "", err
}
return string(bytes), nil
}
}

0 comments on commit 321b2a1

Please sign in to comment.