Skip to content
Snippets Groups Projects
Select Git revision
  • a55548de076f396580bd0aa1196553f5eae61976
  • main default protected
  • rfc-external-artifact
  • release/v2.6.x
  • conform-k8s-1.33
  • release/v2.5.x
  • release/v2.4.x
  • remove-notation-validation
  • release/v2.3.x
  • release/v2.2.x
  • RFC
  • fix-commit-log
  • flux-audit
  • release/v2.1.x
  • context-ns
  • ksm-dashboard
  • rfc-passwordless-git-auth
  • release/v2.0.x
  • rfc-gating
  • release/v0.27.4
  • rfc-0003
  • v2.6.4 protected
  • v2.6.3 protected
  • v2.6.2 protected
  • v2.6.1 protected
  • v2.6.0 protected
  • v2.5.1 protected
  • v2.5.0 protected
  • v2.4.0 protected
  • v2.3.0 protected
  • v2.2.3 protected
  • v2.2.2 protected
  • v2.2.1 protected
  • v2.2.0 protected
  • v2.1.2 protected
  • v2.1.1 protected
  • v2.1.0 protected
  • v2.0.1 protected
  • v2.0.0 protected
  • v2.0.0-rc.5 protected
  • v2.0.0-rc.4 protected
41 results

bootstrap_git.go

Blame
  • bootstrap_git.go 10.72 KiB
    /*
    Copyright 2021 The Flux authors
    
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
    
        http://www.apache.org/licenses/LICENSE-2.0
    
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
    */
    
    package main
    
    import (
    	"context"
    	"fmt"
    	"net/url"
    	"os"
    	"strings"
    	"time"
    
    	"github.com/go-git/go-git/v5/plumbing/transport"
    	"github.com/go-git/go-git/v5/plumbing/transport/http"
    	"github.com/go-git/go-git/v5/plumbing/transport/ssh"
    	"github.com/manifoldco/promptui"
    	"github.com/spf13/cobra"
    	corev1 "k8s.io/api/core/v1"
    
    	"github.com/fluxcd/flux2/internal/bootstrap"
    	"github.com/fluxcd/flux2/internal/bootstrap/git/gogit"
    	"github.com/fluxcd/flux2/internal/flags"
    	"github.com/fluxcd/flux2/internal/utils"
    	"github.com/fluxcd/flux2/pkg/manifestgen"
    	"github.com/fluxcd/flux2/pkg/manifestgen/install"
    	"github.com/fluxcd/flux2/pkg/manifestgen/sourcesecret"
    	"github.com/fluxcd/flux2/pkg/manifestgen/sync"
    )
    
    var bootstrapGitCmd = &cobra.Command{
    	Use:   "git",
    	Short: "Bootstrap toolkit components in a Git repository",
    	Long: `The bootstrap git command commits the toolkit components manifests to the
    branch of a Git repository. It then configures the target cluster to synchronize with
    the repository. If the toolkit components are present on the cluster, the bootstrap
    command will perform an upgrade if needed.`,
    	Example: `  # Run bootstrap for a Git repository and authenticate with your SSH agent
      flux bootstrap git --url=ssh://git@example.com/repository.git
    
      # Run bootstrap for a Git repository and authenticate using a password
      flux bootstrap git --url=https://example.com/repository.git --password=<password>
    
      # Run bootstrap for a Git repository and authenticate using a password from environment variable
      GIT_PASSWORD=<password> && flux bootstrap git --url=https://example.com/repository.git
    
      # Run bootstrap for a Git repository with a passwordless private key
      flux bootstrap git --url=ssh://git@example.com/repository.git --private-key-file=<path/to/private.key>
    
      # Run bootstrap for a Git repository with a private key and password
      flux bootstrap git --url=ssh://git@example.com/repository.git --private-key-file=<path/to/private.key> --password=<password>
    `,
    	RunE: bootstrapGitCmdRun,
    }
    
    type gitFlags struct {
    	url                 string