Set a user-agent for registry pushes. (#87)
This commit is contained in:
parent
b4c8029d60
commit
da1eab7251
6
Makefile
6
Makefile
|
|
@ -18,6 +18,7 @@ VERSION_MINOR ?= 1
|
|||
VERSION_BUILD ?= 0
|
||||
|
||||
VERSION ?= v$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_BUILD)
|
||||
VERSION_PACKAGE = $(REPOPATH/pkg/version)
|
||||
|
||||
GOOS ?= $(shell go env GOOS)
|
||||
GOARCH = amd64
|
||||
|
|
@ -28,7 +29,10 @@ REGISTRY?=gcr.io/kaniko-project
|
|||
REPOPATH ?= $(ORG)/$(PROJECT)
|
||||
|
||||
GO_FILES := $(shell find . -type f -name '*.go' -not -path "./vendor/*")
|
||||
GO_LDFLAGS := '-extldflags "-static"'
|
||||
GO_LDFLAGS := '-extldflags "-static"
|
||||
GO_LDFLAGS += -X $(VERSION_PACKAGE).version=$(VERSION)
|
||||
GO_LDFLAGS += '
|
||||
|
||||
GO_BUILD_TAGS := "containers_image_ostree_stub containers_image_openpgp exclude_graphdriver_devicemapper exclude_graphdriver_btrfs exclude_graphdriver_overlay"
|
||||
|
||||
EXECUTOR_PACKAGE = $(REPOPATH)/executor
|
||||
|
|
|
|||
|
|
@ -18,11 +18,12 @@ package commands
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/GoogleCloudPlatform/kaniko/pkg/util"
|
||||
"github.com/containers/image/manifest"
|
||||
"github.com/docker/docker/builder/dockerfile/instructions"
|
||||
"github.com/sirupsen/logrus"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type ExposeCommand struct {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,12 @@ limitations under the License.
|
|||
package image
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/GoogleCloudPlatform/kaniko/pkg/version"
|
||||
"github.com/containers/image/types"
|
||||
|
||||
img "github.com/GoogleCloudPlatform/container-diff/pkg/image"
|
||||
"github.com/GoogleCloudPlatform/kaniko/pkg/constants"
|
||||
"github.com/containers/image/copy"
|
||||
|
|
@ -24,7 +30,6 @@ import (
|
|||
"github.com/containers/image/signature"
|
||||
"github.com/containers/image/transports/alltransports"
|
||||
"github.com/sirupsen/logrus"
|
||||
"os"
|
||||
)
|
||||
|
||||
// sourceImage is the image that will be modified by the executor
|
||||
|
|
@ -57,7 +62,13 @@ func PushImage(ms *img.MutableSource, destImg string) error {
|
|||
return err
|
||||
}
|
||||
logrus.Infof("Pushing image to %s", destImg)
|
||||
return copy.Image(policyContext, destRef, srcRef, nil)
|
||||
|
||||
opts := ©.Options{
|
||||
DestinationCtx: &types.SystemContext{
|
||||
DockerRegistryUserAgent: fmt.Sprintf("kaniko/executor-%s", version.Version()),
|
||||
},
|
||||
}
|
||||
return copy.Image(policyContext, destRef, srcRef, opts)
|
||||
}
|
||||
|
||||
// SetEnvVariables sets environment variables as specified in the image
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
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 version
|
||||
|
||||
// Set with LDFLAGS
|
||||
var version = "unset"
|
||||
|
||||
func Version() string {
|
||||
return version
|
||||
}
|
||||
Loading…
Reference in New Issue