github.com/alibaba/sealer@v0.8.6-0.20220430115802-37a2bdaa8173/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  	"fmt"
    19  	"os"
    20  	"path/filepath"
    21  	"time"
    22  
    23  	"github.com/mitchellh/go-homedir"
    24  )
    25  
    26  const (
    27  	SealerBinPath                     = "/usr/local/bin/sealer"
    28  	ImageName                         = "sealer_test_image_"
    29  	DefaultImageDomain                = "registry.cn-qingdao.aliyuncs.com"
    30  	DefaultImageRepo                  = "sealer-io"
    31  	DefaultImageName                  = "kubernetes:v1.19.8"
    32  	DefaultRegistryAuthFileDir        = "/root/.docker"
    33  	DefaultClusterFileNeedToBeCleaned = "/root/.sealer/%s/Clusterfile"
    34  	SubCmdBuildOfSealer               = "build"
    35  	SubCmdApplyOfSealer               = "apply"
    36  	SubCmdDeleteOfSealer              = "delete"
    37  	SubCmdRunOfSealer                 = "run"
    38  	SubCmdLoginOfSealer               = "login"
    39  	SubCmdTagOfSealer                 = "tag"
    40  	SubCmdPullOfSealer                = "pull"
    41  	SubCmdListOfSealer                = "images"
    42  	SubCmdPushOfSealer                = "push"
    43  	SubCmdRmiOfSealer                 = "rmi"
    44  	DefaultSSHPassword                = "Sealer123"
    45  	ImageAnnotationForClusterfile     = "sea.aliyun.com/ClusterFile"
    46  )
    47  
    48  const (
    49  	FileMode0755 = 0755
    50  	FileMode0644 = 0644
    51  )
    52  const (
    53  	LiteBuild = "lite"
    54  )
    55  const (
    56  	BAREMETAL         = "BAREMETAL"
    57  	AliCloud          = "ALI_CLOUD"
    58  	CONTAINER         = "CONTAINER"
    59  	DefaultImage      = "registry.cn-qingdao.aliyuncs.com/sealer-io/kubernetes:v1.19.8"
    60  	DefaultNydusImage = "registry.cn-qingdao.aliyuncs.com/sealer-io/kubernetes-nydus:v1.19.8"
    61  	ClusterNameForRun = "my-cluster"
    62  	TMPClusterFile    = "/tmp/Clusterfile"
    63  	ClusterWorkDir    = "/root/.sealer/%s"
    64  )
    65  
    66  var (
    67  	DefaultPollingInterval time.Duration
    68  	MaxWaiteTime           time.Duration
    69  	DefaultWaiteTime       time.Duration
    70  	DefaultSealerBin       = ""
    71  	DefaultTestEnvDir      = ""
    72  	RegistryURL            = os.Getenv("REGISTRY_URL")
    73  	RegistryUsername       = os.Getenv("REGISTRY_USERNAME")
    74  	RegistryPasswd         = os.Getenv("REGISTRY_PASSWORD")
    75  	CustomImageName        = os.Getenv("IMAGE_NAME")
    76  	CustomNydusImageName   = os.Getenv("NYDUS_IMAGE_NAME")
    77  
    78  	AccessKey          = os.Getenv("ACCESSKEYID")
    79  	AccessSecret       = os.Getenv("ACCESSKEYSECRET")
    80  	Region             = os.Getenv("RegionID")
    81  	TestImageName      = "" //default: registry.cn-qingdao.aliyuncs.com/sealer-io/kubernetes:v1.19.8
    82  	TestNydusImageName = "" //default: registry.cn-qingdao.aliyuncs.com/sealer-io/kubernetes-nydus:v1.19.8
    83  )
    84  
    85  func GetClusterWorkDir(clusterName string) string {
    86  	home, err := homedir.Dir()
    87  	if err != nil {
    88  		return fmt.Sprintf(ClusterWorkDir, clusterName)
    89  	}
    90  	return filepath.Join(home, ".sealer", clusterName)
    91  }
    92  
    93  func GetClusterWorkClusterfile(clusterName string) string {
    94  	return filepath.Join(GetClusterWorkDir(clusterName), "Clusterfile")
    95  }