mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-10-18 01:41:02 +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
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ limitations under the License.
|
||||
package commands
|
||||
|
||||
import (
|
||||
"github.com/docker/docker/builder/dockerfile"
|
||||
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ limitations under the License.
|
||||
package commands
|
||||
|
||||
import (
|
||||
"github.com/docker/docker/builder/dockerfile"
|
||||
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
||||
"github.com/docker/docker/builder/dockerfile/instructions"
|
||||
"github.com/google/go-containerregistry/v1"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ limitations under the License.
|
||||
package commands
|
||||
|
||||
import (
|
||||
"github.com/docker/docker/builder/dockerfile"
|
||||
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/docker/builder/dockerfile/instructions"
|
||||
|
||||
@@ -17,7 +17,7 @@ limitations under the License.
|
||||
package commands
|
||||
|
||||
import (
|
||||
"github.com/docker/docker/builder/dockerfile"
|
||||
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
||||
"github.com/docker/docker/builder/dockerfile/instructions"
|
||||
"github.com/google/go-containerregistry/v1"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
@@ -22,8 +22,8 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
||||
"github.com/GoogleContainerTools/kaniko/pkg/util"
|
||||
"github.com/docker/docker/builder/dockerfile"
|
||||
"github.com/docker/docker/builder/dockerfile/instructions"
|
||||
"github.com/google/go-containerregistry/v1"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
@@ -17,7 +17,7 @@ limitations under the License.
|
||||
package commands
|
||||
|
||||
import (
|
||||
"github.com/docker/docker/builder/dockerfile"
|
||||
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/docker/builder/dockerfile/instructions"
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ limitations under the License.
|
||||
package commands
|
||||
|
||||
import (
|
||||
"github.com/docker/docker/builder/dockerfile"
|
||||
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
||||
"strings"
|
||||
|
||||
"github.com/GoogleContainerTools/kaniko/pkg/util"
|
||||
|
||||
@@ -18,7 +18,6 @@ package commands
|
||||
import (
|
||||
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
||||
"github.com/GoogleContainerTools/kaniko/testutil"
|
||||
docker "github.com/docker/docker/builder/dockerfile"
|
||||
"github.com/docker/docker/builder/dockerfile/instructions"
|
||||
"github.com/google/go-containerregistry/v1"
|
||||
"testing"
|
||||
@@ -98,7 +97,7 @@ func Test_EnvExecute(t *testing.T) {
|
||||
testutil.CheckErrorAndDeepEqual(t, false, err, expectedEnvs, cfg.Env)
|
||||
}
|
||||
|
||||
func setUpBuildArgs() *docker.BuildArgs {
|
||||
func setUpBuildArgs() *dockerfile.BuildArgs {
|
||||
buildArgs := dockerfile.NewBuildArgs([]string{
|
||||
"buildArg1=foo",
|
||||
"buildArg2=foo2",
|
||||
|
||||
@@ -18,7 +18,7 @@ package commands
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/docker/docker/builder/dockerfile"
|
||||
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
||||
"strings"
|
||||
|
||||
"github.com/GoogleContainerTools/kaniko/pkg/util"
|
||||
|
||||
@@ -17,7 +17,7 @@ limitations under the License.
|
||||
package commands
|
||||
|
||||
import (
|
||||
"github.com/docker/docker/builder/dockerfile"
|
||||
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
||||
"strings"
|
||||
|
||||
"github.com/GoogleContainerTools/kaniko/pkg/util"
|
||||
|
||||
@@ -17,8 +17,8 @@ limitations under the License.
|
||||
package commands
|
||||
|
||||
import (
|
||||
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
||||
"github.com/GoogleContainerTools/kaniko/pkg/util"
|
||||
"github.com/docker/docker/builder/dockerfile"
|
||||
"github.com/docker/docker/builder/dockerfile/instructions"
|
||||
"github.com/google/go-containerregistry/v1"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
+1
-1
@@ -17,8 +17,8 @@ limitations under the License.
|
||||
package commands
|
||||
|
||||
import (
|
||||
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
||||
"github.com/GoogleContainerTools/kaniko/pkg/util"
|
||||
"github.com/docker/docker/builder/dockerfile"
|
||||
"github.com/docker/docker/builder/dockerfile/instructions"
|
||||
"github.com/google/go-containerregistry/v1"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
@@ -17,7 +17,7 @@ limitations under the License.
|
||||
package commands
|
||||
|
||||
import (
|
||||
"github.com/docker/docker/builder/dockerfile"
|
||||
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
||||
"github.com/docker/docker/builder/dockerfile/instructions"
|
||||
"github.com/google/go-containerregistry/v1"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
@@ -17,8 +17,8 @@ limitations under the License.
|
||||
package commands
|
||||
|
||||
import (
|
||||
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
||||
"github.com/GoogleContainerTools/kaniko/pkg/util"
|
||||
"github.com/docker/docker/builder/dockerfile"
|
||||
"github.com/docker/docker/builder/dockerfile/instructions"
|
||||
"github.com/docker/docker/pkg/signal"
|
||||
"github.com/google/go-containerregistry/v1"
|
||||
|
||||
@@ -17,8 +17,8 @@ limitations under the License.
|
||||
package commands
|
||||
|
||||
import (
|
||||
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
||||
"github.com/GoogleContainerTools/kaniko/pkg/util"
|
||||
"github.com/docker/docker/builder/dockerfile"
|
||||
"github.com/docker/docker/builder/dockerfile/instructions"
|
||||
"github.com/google/go-containerregistry/v1"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
@@ -17,7 +17,7 @@ limitations under the License.
|
||||
package commands
|
||||
|
||||
import (
|
||||
"github.com/docker/docker/builder/dockerfile"
|
||||
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ limitations under the License.
|
||||
package commands
|
||||
|
||||
import (
|
||||
"github.com/docker/docker/builder/dockerfile"
|
||||
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
|
||||
@@ -21,7 +21,11 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func NewBuildArgs(args []string) *d.BuildArgs {
|
||||
type BuildArgs struct {
|
||||
d.BuildArgs
|
||||
}
|
||||
|
||||
func NewBuildArgs(args []string) *BuildArgs {
|
||||
argsFromOptions := make(map[string]*string)
|
||||
for _, a := range args {
|
||||
s := strings.Split(a, "=")
|
||||
@@ -31,5 +35,7 @@ func NewBuildArgs(args []string) *d.BuildArgs {
|
||||
argsFromOptions[s[0]] = &s[1]
|
||||
}
|
||||
}
|
||||
return d.NewBuildArgs(argsFromOptions)
|
||||
return &BuildArgs{
|
||||
*d.NewBuildArgs(argsFromOptions),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ limitations under the License.
|
||||
package util
|
||||
|
||||
import (
|
||||
"github.com/docker/docker/builder/dockerfile"
|
||||
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
|
||||
"github.com/docker/docker/builder/dockerfile/instructions"
|
||||
"github.com/docker/docker/builder/dockerfile/parser"
|
||||
"github.com/docker/docker/builder/dockerfile/shell"
|
||||
|
||||
Reference in New Issue
Block a user