github.com/sealerio/sealer@v0.11.1-0.20240507115618-f4f89c5853ae/test/testhelper/settings/common.go (about)

     1  // Copyright © 2021 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 settings
    16  
    17  import (
    18  	"os"
    19  	"path/filepath"
    20  	"time"
    21  
    22  	"github.com/mitchellh/go-homedir"
    23  )
    24  
    25  const (
    26  	SealerBinPath                     = "/usr/local/bin/sealer"
    27  	DefaultImageDomain                = "docker.io"
    28  	DefaultImageRepo                  = "sealerio"
    29  	DefaultImageName                  = "kubernetes:v1-22-15-sealerio-2"
    30  	DefaultRegistryAuthFileDir        = "/root/.docker"
    31  	DefaultClusterFileNeedToBeCleaned = "/root/.sealer/%s/Clusterfile"
    32  	SealerImageRootPath               = "/var/lib/sealer"
    33  )
    34  
    35  const (
    36  	FileMode0755 = 0755
    37  	FileMode0644 = 0644
    38  )
    39  const (
    40  	LiteBuild = "lite"
    41  )
    42  const (
    43  	BAREMETAL         = "BAREMETAL"
    44  	AliCloud          = "ALI_CLOUD"
    45  	CONTAINER         = "CONTAINER"
    46  	DefaultImage      = "docker.io/sealerio/kubernetes:v1-22-15-sealerio-2"
    47  	DefaultNydusImage = "registry.cn-qingdao.aliyuncs.com/sealer-io/kubernetes-nydus:v1.19.8"
    48  	ClusterNameForRun = "my-cluster"
    49  	TMPClusterFile    = "/tmp/Clusterfile"
    50  	ClusterWorkDir    = "/root/.sealer"
    51  )
    52  
    53  var (
    54  	DefaultPollingInterval time.Duration
    55  	MaxWaiteTime           time.Duration
    56  	DefaultWaiteTime       time.Duration
    57  	DefaultSealerBin       = ""
    58  	DefaultTestEnvDir      = ""
    59  	RegistryURL            = os.Getenv("REGISTRY_URL")
    60  	RegistryUsername       = os.Getenv("REGISTRY_USERNAME")
    61  	RegistryPasswd         = os.Getenv("REGISTRY_PASSWORD")
    62  	CustomImageName        = os.Getenv("IMAGE_NAME")
    63  	CustomNydusImageName   = os.Getenv("NYDUS_IMAGE_NAME")
    64  
    65  	AccessKey          = os.Getenv("ACCESSKEYID")
    66  	AccessSecret       = os.Getenv("ACCESSKEYSECRET")
    67  	Region             = os.Getenv("RegionID")
    68  	TestImageName      = DefaultImage                                                               //default: docker.io/sealerio/kubernetes:v1-22-15-sealerio-2
    69  	TestNydusImageName = "registry.cn-qingdao.aliyuncs.com/sealer-io/kubernetes-nydus:v1.19.8.test" //default: registry.cn-qingdao.aliyuncs.com/sealer-io/kubernetes-nydus:v1.19.8
    70  )
    71  
    72  func GetClusterWorkDir(clusterName string) string {
    73  	home, err := homedir.Dir()
    74  	if err != nil {
    75  		return filepath.Join(ClusterWorkDir, clusterName)
    76  	}
    77  	return filepath.Join(home, ".sealer", clusterName)
    78  }
    79  
    80  func GetClusterWorkClusterfile(clusterName string) string {
    81  	return filepath.Join(GetClusterWorkDir(clusterName), "Clusterfile")
    82  }