github.com/webmeshproj/webmesh-cni@v0.0.27/internal/cmd/install/install.go (about)

     1  /*
     2  Copyright 2023 Avi Zimmerman <avi.zimmerman@gmail.com>.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  // Package install contains the entrypoint for the webmesh-cni install component.
    18  package install
    19  
    20  import (
    21  	"flag"
    22  	"log"
    23  	"os"
    24  
    25  	"github.com/webmeshproj/webmesh/pkg/version"
    26  
    27  	"github.com/webmeshproj/webmesh-cni/internal/types"
    28  )
    29  
    30  // Main ensures the CNI binaries and configuration are installed on the host system.
    31  func Main(version version.BuildInfo) {
    32  	conf := types.LoadInstallOptionsFromEnv()
    33  	conf.BindFlags(flag.CommandLine)
    34  	flag.Parse()
    35  	log.Printf("installing webmesh-cni, version: %s", version.Version)
    36  	err := conf.Validate()
    37  	if err != nil {
    38  		log.Println("install options are invalid:", err)
    39  		os.Exit(1)
    40  	}
    41  	log.Printf("installing webmesh-cni with options:\n%s", conf.String())
    42  	err = conf.RunInstall()
    43  	if err != nil {
    44  		log.Println("error running install:", err)
    45  		os.Exit(1)
    46  	}
    47  	log.Println("webmesh-cni install complete!")
    48  }