mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-10-20 14:25:56 +02:00
Wrap BuildArgs in our own type
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
Copyright 2018 Google LLC
|
||||
|
||||
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 cmd
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// The buildArg type is used to pass in multiple --build-arg flags
|
||||
type buildArg []string
|
||||
|
||||
// Now, for our new type, implement the two methods of
|
||||
// the flag.Value interface...
|
||||
// The first method is String() string
|
||||
func (b *buildArg) String() string {
|
||||
return strings.Join(*b, ",")
|
||||
}
|
||||
|
||||
// The second method is Set(value string) error
|
||||
func (b *buildArg) Set(value string) error {
|
||||
logrus.Infof("appending to build args %s", value)
|
||||
*b = append(*b, value)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *buildArg) Type() string {
|
||||
return "build-arg type"
|
||||
}
|
||||
@@ -23,7 +23,6 @@ import (
|
||||
|
||||
"github.com/GoogleContainerTools/kaniko/pkg/executor"
|
||||
"github.com/genuinetools/amicontained/container"
|
||||
"strings"
|
||||
|
||||
"github.com/GoogleContainerTools/kaniko/pkg/constants"
|
||||
"github.com/GoogleContainerTools/kaniko/pkg/util"
|
||||
@@ -86,26 +85,6 @@ var RootCmd = &cobra.Command{
|
||||
},
|
||||
}
|
||||
|
||||
type buildArg []string
|
||||
|
||||
// Now, for our new type, implement the two methods of
|
||||
// the flag.Value interface...
|
||||
// The first method is String() string
|
||||
func (b *buildArg) String() string {
|
||||
return strings.Join(*b, ",")
|
||||
}
|
||||
|
||||
// The second method is Set(value string) error
|
||||
func (b *buildArg) Set(value string) error {
|
||||
logrus.Infof("appending to build args %s", value)
|
||||
*b = append(*b, value)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *buildArg) Type() string {
|
||||
return "Build ARG Type"
|
||||
}
|
||||
|
||||
func checkContained() bool {
|
||||
_, err := container.DetectRuntime()
|
||||
return err == nil
|
||||
|
||||
Reference in New Issue
Block a user