github.com/GoogleContainerTools/skaffold@v1.39.18/pkg/skaffold/git/errors.go (about)

     1  /*
     2  Copyright 2021 The Skaffold Authors
     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 git
    18  
    19  import (
    20  	"fmt"
    21  
    22  	sErrors "github.com/GoogleContainerTools/skaffold/pkg/skaffold/errors"
    23  	"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
    24  	"github.com/GoogleContainerTools/skaffold/proto/v1"
    25  )
    26  
    27  // SyncDisabledErr returns error when git repository sync is turned off by the user but the repository clone doesn't exist inside the cache directory.
    28  func SyncDisabledErr(g latest.GitInfo, repoCacheDir string) error {
    29  	msg := fmt.Sprintf("cache directory %q for repository %q at ref %q does not exist, and repository sync is explicitly disabled via flag `--sync-remote-cache`", repoCacheDir, g.Repo, g.Ref)
    30  	return sErrors.NewError(fmt.Errorf(msg),
    31  		&proto.ActionableErr{
    32  			Message: msg,
    33  			ErrCode: proto.StatusCode_CONFIG_REMOTE_REPO_CACHE_NOT_FOUND_ERR,
    34  			Suggestions: []*proto.Suggestion{
    35  				{
    36  					SuggestionCode: proto.SuggestionCode_CONFIG_ENABLE_REMOTE_REPO_SYNC,
    37  					Action:         fmt.Sprintf("Either clone the repository manually inside %q, or set flag `--sync-remote-cache` to `always` or `missing`", repoCacheDir),
    38  				},
    39  			},
    40  		})
    41  }