2022-02-28 15:34:50 +01:00
|
|
|
// Copyright 2022 Google LLC All Rights Reserved.
|
|
|
|
//
|
|
|
|
// 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 options
|
|
|
|
|
2022-06-01 13:28:38 +02:00
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"strings"
|
|
|
|
)
|
2022-02-28 15:34:50 +01:00
|
|
|
|
|
|
|
const bareBaseFlagsWarning = `WARNING!
|
|
|
|
-----------------------------------------------------------------
|
|
|
|
Both --base-import-paths and --bare were set.
|
|
|
|
|
|
|
|
--base-import-paths will take precedence and ignore --bare flag.
|
|
|
|
|
|
|
|
In a future release this will be an error.
|
|
|
|
-----------------------------------------------------------------
|
|
|
|
`
|
|
|
|
|
2022-06-01 13:28:38 +02:00
|
|
|
const localFlagsWarning = `WARNING!
|
|
|
|
-----------------------------------------------------------------
|
|
|
|
The --local flag is set and KO_DOCKER_REPO is set to ko.local
|
|
|
|
|
|
|
|
You can choose either one to build a local image.
|
|
|
|
|
|
|
|
The --local flag might be deprecated in the future.
|
|
|
|
-----------------------------------------------------------------
|
|
|
|
`
|
|
|
|
|
2022-02-28 15:34:50 +01:00
|
|
|
func Validate(po *PublishOptions, bo *BuildOptions) error {
|
|
|
|
if po.Bare && po.BaseImportPaths {
|
|
|
|
log.Print(bareBaseFlagsWarning)
|
|
|
|
// TODO: return error when we decided to make this an error, for now it is a warning
|
|
|
|
}
|
|
|
|
|
2022-06-01 13:28:38 +02:00
|
|
|
if po.Local && strings.Contains(po.DockerRepo, "ko.local") {
|
|
|
|
log.Print(localFlagsWarning)
|
|
|
|
}
|
|
|
|
|
2022-02-28 15:34:50 +01:00
|
|
|
return nil
|
|
|
|
}
|