github.com/sealerio/sealer@v0.11.1-0.20240507115618-f4f89c5853ae/pkg/application/interface.go (about)

     1  // Copyright © 2022 Alibaba Group Holding Ltd.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package application
    16  
    17  import (
    18  	"github.com/sealerio/sealer/pkg/infradriver"
    19  	v2 "github.com/sealerio/sealer/types/api/v2"
    20  )
    21  
    22  // Interface works like application driver,
    23  // it converts Application fields, such as app configs, app global envs, app image names and so on.
    24  type Interface interface {
    25  	// GetImageLaunchCmds :its image level. get entire application launch commands
    26  	// return appended each app launch cmds Or globalCmds.
    27  	GetImageLaunchCmds() []string
    28  
    29  	// GetAppLaunchCmds :get application launch commands from configs
    30  	// return Launch.Cmds firstly Or wrapper application commands through its type.
    31  	GetAppLaunchCmds(appName string) []string
    32  
    33  	// GetAppNames :get application name list
    34  	// return spec.AppNames
    35  	GetAppNames() []string
    36  
    37  	//GetAppRoot :get appRoot path by its name.
    38  	GetAppRoot(appName string) string
    39  
    40  	// GetDeleteCmds :get application delete commands from configs
    41  	// return Delete.Cmds firstly Or wrapper application commands through its type.
    42  	//GetDeleteCmds(appName string) []string
    43  
    44  	// FileProcess :Process application file using at mount stage to modify build app files.
    45  	FileProcess(mountDir string) error
    46  
    47  	// GetApplication :get application spec
    48  	// return v2.Application
    49  	GetApplication() v2.Application
    50  
    51  	//GetImageName ()string
    52  	//GetGlobalEnv() map[string]interface{}
    53  	//AddGlobalEnv(envs []string)
    54  
    55  	Launch(infraDriver infradriver.InfraDriver) error
    56  
    57  	Save(opts SaveOptions) error
    58  }
    59  
    60  type FileProcessor interface {
    61  	//Process application files though ValueType
    62  	// currently Processor register as blew:
    63  	// overWriteProcessor: this will overwrite the FilePath with the Values.
    64  	// renderProcessor: this will render the FilePath with the Values.
    65  	Process(appRoot string) error
    66  }