mirror of
				https://github.com/kata-containers/kata-containers.git
				synced 2025-10-31 09:26:52 +00:00 
			
		
		
		
	runtime: use concrete KataAgentConfig instead of interface type
Kata Containers 2.0 only have one type of agent, so there is no need to use interface as config's type Fixes: #1610 Signed-off-by: bin <bin@hyper.sh>
This commit is contained in:
		| @@ -163,10 +163,10 @@ type agent interface { | |||||||
| 	resumeContainer(ctx context.Context, sandbox *Sandbox, c Container) error | 	resumeContainer(ctx context.Context, sandbox *Sandbox, c Container) error | ||||||
|  |  | ||||||
| 	// configure will update agent settings based on provided arguments | 	// configure will update agent settings based on provided arguments | ||||||
| 	configure(ctx context.Context, h hypervisor, id, sharePath string, config interface{}) error | 	configure(ctx context.Context, h hypervisor, id, sharePath string, config KataAgentConfig) error | ||||||
|  |  | ||||||
| 	// configureFromGrpc will update agent settings based on provided arguments which from Grpc | 	// configureFromGrpc will update agent settings based on provided arguments which from Grpc | ||||||
| 	configureFromGrpc(h hypervisor, id string, config interface{}) error | 	configureFromGrpc(h hypervisor, id string, config KataAgentConfig) error | ||||||
|  |  | ||||||
| 	// reseedRNG will reseed the guest random number generator | 	// reseedRNG will reseed the guest random number generator | ||||||
| 	reseedRNG(ctx context.Context, data []byte) error | 	reseedRNG(ctx context.Context, data []byte) error | ||||||
|   | |||||||
| @@ -368,19 +368,12 @@ func (k *kataAgent) capabilities() types.Capabilities { | |||||||
| 	return caps | 	return caps | ||||||
| } | } | ||||||
|  |  | ||||||
| func (k *kataAgent) internalConfigure(h hypervisor, id string, config interface{}) error { | func (k *kataAgent) internalConfigure(h hypervisor, id string, config KataAgentConfig) error { | ||||||
| 	var err error | 	var err error | ||||||
| 	if config != nil { |  | ||||||
| 		switch c := config.(type) { |  | ||||||
| 		case KataAgentConfig: |  | ||||||
| 	if k.vmSocket, err = h.generateSocket(id); err != nil { | 	if k.vmSocket, err = h.generateSocket(id); err != nil { | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
| 			k.keepConn = c.LongLiveConn | 	k.keepConn = config.LongLiveConn | ||||||
| 		default: |  | ||||||
| 			return vcTypes.ErrInvalidConfigType |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
| @@ -429,7 +422,7 @@ func cleanupSandboxBindMounts(sandbox *Sandbox) error { | |||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
|  |  | ||||||
| func (k *kataAgent) configure(ctx context.Context, h hypervisor, id, sharePath string, config interface{}) error { | func (k *kataAgent) configure(ctx context.Context, h hypervisor, id, sharePath string, config KataAgentConfig) error { | ||||||
| 	err := k.internalConfigure(h, id, config) | 	err := k.internalConfigure(h, id, config) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return err | 		return err | ||||||
| @@ -471,7 +464,7 @@ func (k *kataAgent) configure(ctx context.Context, h hypervisor, id, sharePath s | |||||||
| 	return h.addDevice(ctx, sharedVolume, fsDev) | 	return h.addDevice(ctx, sharedVolume, fsDev) | ||||||
| } | } | ||||||
|  |  | ||||||
| func (k *kataAgent) configureFromGrpc(h hypervisor, id string, config interface{}) error { | func (k *kataAgent) configureFromGrpc(h hypervisor, id string, config KataAgentConfig) error { | ||||||
| 	return k.internalConfigure(h, id, config) | 	return k.internalConfigure(h, id, config) | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -176,12 +176,12 @@ func (n *mockAgent) resumeContainer(ctx context.Context, sandbox *Sandbox, c Con | |||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
|  |  | ||||||
| // configHypervisor is the Noop agent hypervisor configuration implementation. It does nothing. | // configure is the Noop agent configuration implementation. It does nothing. | ||||||
| func (n *mockAgent) configure(ctx context.Context, h hypervisor, id, sharePath string, config interface{}) error { | func (n *mockAgent) configure(ctx context.Context, h hypervisor, id, sharePath string, config KataAgentConfig) error { | ||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
|  |  | ||||||
| func (n *mockAgent) configureFromGrpc(h hypervisor, id string, config interface{}) error { | func (n *mockAgent) configureFromGrpc(h hypervisor, id string, config KataAgentConfig) error { | ||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user