Skip to content

Feature: Refactoring sealos run will remember the env and cmd all the time #3665

@cuisongliu

Description

@cuisongliu

What is the problem this feature will solve?

sealos currently has some rendering and execution problems, and cannot be separated from the image. The best way is that the mirror has its own cmd and env

If you have solution,please describe it

It may be necessary to fix the clusterfile spec.

current:

type ImageList []string

// ClusterSpec defines the desired state of InfraMetadata
type ClusterSpec struct {
	// desired state of cluster
	// Important: Run "make" to regenerate code after modifying this file
	// Foo is an example field of Cluster. Edit Cluster_types.go to remove/update
	Image ImageList `json:"image,omitempty"`
	SSH   SSH       `json:"ssh"`
	Hosts []Host    `json:"hosts,omitempty"`
	// Why env not using map[string]string
	// Because some argument is list, like: CertSANS=127.0.0.1 CertSANS=localhost, if ENV is map, will merge those two values
	// but user want to InfraMetadata a list, using array we can convert it to {CertSANS:[127.0.0.1, localhost]}
	Env []string `json:"env,omitempty"`
	// Entrypoint array. Not executed within a shell.
	// The docker image's ENTRYPOINT is used if this is not provided.
	// Variable references $(VAR_NAME) are expanded using the container's environment. If a variable
	// cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced
	// to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will
	// produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless
	// of whether the variable exists or not. Cannot be updated.
	// More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell
	// +optional
	Command []string `json:"command,omitempty"`
}

new spec :

type ImageSpec struct {
       Name string
       // Why env not using map[string]string
	// Because some argument is list, like: CertSANS=127.0.0.1 CertSANS=localhost, if ENV is map, will merge those two values
	// but user want to InfraMetadata a list, using array we can convert it to {CertSANS:[127.0.0.1, localhost]}
	Env []string `json:"env,omitempty"`
	// Entrypoint array. Not executed within a shell.
	// The docker image's ENTRYPOINT is used if this is not provided.
	// Variable references $(VAR_NAME) are expanded using the container's environment. If a variable
	// cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced
	// to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will
	// produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless
	// of whether the variable exists or not. Cannot be updated.
	// More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell
	// +optional
	Command []string `json:"command,omitempty"`
}

// ClusterSpec defines the desired state of InfraMetadata
type ClusterSpec struct {
	// desired state of cluster
	// Important: Run "make" to regenerate code after modifying this file
	// Foo is an example field of Cluster. Edit Cluster_types.go to remove/update
	Image []ImageSpec `json:"image,omitempty"`
	SSH   SSH       `json:"ssh"`
	Hosts []Host    `json:"hosts,omitempty"`	
}

What alternatives have you considered?

Type Improvements Issue PR Status
🚀 Feature Design a new cluster type spec. #3657, #2046,#3677
🔨 Enhancement Implement the new cluster type spec. support apply and guest to using sealos run.
🧪 Testing Provide unit testing and CI flow to ensure code quality
🎯 Fix The current logic of sealos run will parse the environment variable $, which inevitably needs to be fixed. #2861 #2862

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions