Permalink
Browse files

resolve #169 and remove freebsd from release builds

  • Loading branch information...
LukasGentele committed Sep 15, 2018
1 parent 25b6eb9 commit 8e2ad1523f271ea78de968a031215d42b454b018
View
@@ -31,26 +31,26 @@ jobs:
deploy:
- provider: releases
file:
- release/devspace-linux-amd64
- release/devspace-linux-amd64.sha256
- release/devspace-darwin-amd64
- release/devspace-darwin-amd64.sha256
- release/devspace-freebsd-amd64
- release/devspace-freebsd-amd64.sha256
- release/devspace-windows-amd64.exe
- release/devspace-windows-amd64.exe.sha256
- release/devspace-linux-386
- release/devspace-linux-386.sha256
- release/devspace-darwin-386
- release/devspace-darwin-386.sha256
- release/devspace-freebsd-386
- release/devspace-freebsd-386.sha256
- release/devspace-windows-386.exe
- release/devspace-windows-386.exe.sha256
- release/devspace-darwin-amd64
- release/devspace-darwin-amd64.sha256
- release/devspace-darwin-386
- release/devspace-darwin-386.sha256
- release/devspace-linux-amd64
- release/devspace-linux-amd64.sha256
- release/devspace-linux-386
- release/devspace-linux-386.sha256
- release/devspace-linux-ppc64
- release/devspace-linux-ppc64.sha256
- release/devspace-linux-ppc64le
- release/devspace-linux-ppc64le.sha256
# - release/devspace-freebsd-amd64
# - release/devspace-freebsd-amd64.sha256
# - release/devspace-freebsd-386
# - release/devspace-freebsd-386.sha256
skip_cleanup: true
api_key:
secure: "KGCqYQmeEirDMoghu88D4hzUaG6ypBIFlY+QBtqlvyIbjbkyoOJ2cYJlcGG3SVssnXHgNQFGa8OZJosjVysNQorYY2P4ckF/V0GM+u0mSAeRcSSrorMOL6c8UQEY5695st2VqZBFtlpW7mNo75pU6Xgkcqhxb4/j/aj0I/+vhHbakFAQXcC6iMsuKQqRkXsh7g/G5/xgc2oxxK7dcfbJqC4QeUddKX0bZdLyml4yVrrI9XR/7bS1h+Q5S6ZyJ2EO3HRE7h6hAuGU21R4lrzRpDJh7Kopg4Fo6zqrU8lF3/Gw+RtmkWGoo6tXn+r6+HBu8xSbkw0NhGdL2iKraE2pOkRDlYZsR1XTNM5WKRMx+cZGY0OJT+Q04/5hs8uIuGwEATOZ2IAj2AWMba750Hx5h18dyLijpvSjNPtPo+ki0MYbMyYuZtlQDqvBfOclLfKoScsHz9ffGf0oz7p9/Z0riLIaMLmQXY5Zq3OSXATnXBAfgwtOppgR1foUKYb0P92uPePYIsmZN+p2HZDgS1nP2++Mg33BCLf+HUVhyekGc+wLbcEZTz49FCPjDRhGZz7FGe1ovvnYmtr00gaUcR6pq2nJGackkTOeuggu5ahmcc6xtFBxRT/JHi+LCeoqESsi6mvF7QEK4Widpn+sFwbAZlhGUVzhYnwfDNM9RK1pF+Q="
View
129 cmd/up.go
@@ -8,6 +8,10 @@ import (
"strings"
"time"
"github.com/covexo/devspace/pkg/util/yamlutil"
"github.com/covexo/devspace/pkg/devspace/builder"
"github.com/docker/docker/api/types"
"github.com/covexo/devspace/pkg/devspace/builder/docker"
@@ -214,12 +218,21 @@ func (cmd *UpCmd) initRegistries() {
}
for registryName, registryConf := range registryMap {
log.StartWait("Creating image pull secret for registry: " + registryName)
err := registry.CreatePullSecret(cmd.kubectl, *config.DevSpace.Release.Namespace, registryConf)
log.StopWait()
if registryConf.Auth != nil && registryConf.Auth.Password != nil {
username := ""
password := *registryConf.Auth.Password
email := "noreply@devspace-cloud.com"
if err != nil {
log.Fatalf("Failed to create pull secret for registry: %v", err)
if registryConf.Auth.Username != nil {
username = *registryConf.Auth.Username
}
log.StartWait("Creating image pull secret for registry: " + registryName)
err := registry.CreatePullSecret(cmd.kubectl, *config.DevSpace.Release.Namespace, *registryConf.URL, username, password, email)
log.StopWait()
if err != nil {
log.Fatalf("Failed to create pull secret for registry: %v", err)
}
}
}
}
@@ -285,66 +298,74 @@ func (cmd *UpCmd) buildImages(buildFlagChanged bool) bool {
log.Fatal(registryErr)
}
var buildErr error
var imageBuilder builder.BuilderInterface
buildInfo := "Building image '%s' with engine '%s'"
if imageConf.Build.Engine.Kaniko != nil {
log.Infof(buildInfo, imageName, "kaniko")
registryURL := *registryConf.URL
imageDestination := registry.GetImageURL(imageConf, false) + ":" + imageTag
if registryURL == "hub.docker.com" {
registryURL = ""
}
engineName := ""
buildErr = kaniko.BuildDockerfile(cmd.kubectl, *config.DevSpace.Release.Namespace, imageDestination, registry.PullSecretName, *registryConf.Insecure)
} else {
log.Infof(buildInfo, imageName, "docker")
if imageConf.Build.Engine.Kaniko != nil {
engineName = "kaniko"
buildNamespace := *config.DevSpace.Release.Namespace
allowInsecurePush := false
var dockerBuilder *docker.Builder
if imageConf.Build.Engine.Kaniko.Namespace != nil {
buildNamespace = *imageConf.Build.Engine.Kaniko.Namespace
}
if registryConf.Insecure != nil {
allowInsecurePush = *registryConf.Insecure
}
imageBuilder, buildErr = kaniko.NewBuilder(registryURL, *imageConf.Name, imageTag, buildNamespace, cmd.kubectl, allowInsecurePush)
} else {
engineName = "docker"
preferMinikube := true
if imageConf.Build.Engine.Docker.PreferMinikube != nil {
preferMinikube = *imageConf.Build.Engine.Docker.PreferMinikube
}
registryURL := *registryConf.URL
imageBuilder, buildErr = docker.NewBuilder(registryURL, *imageConf.Name, imageTag, preferMinikube)
}
log.Infof(buildInfo, imageName, engineName)
if buildErr == nil {
username := ""
password := ""
if registryURL == "hub.docker.com" {
registryURL = ""
if registryConf.Auth != nil {
if registryConf.Auth.Username != nil {
username = *registryConf.Auth.Username
}
if registryConf.Auth.Password != nil {
password = *registryConf.Auth.Password
}
}
dockerBuilder, buildErr = docker.NewBuilder(registryURL, *imageConf.Name, imageTag, preferMinikube)
log.StartWait("Authenticating (" + *registryConf.URL + ")")
_, buildErr = imageBuilder.Authenticate(username, password, len(username) == 0)
log.StopWait()
if buildErr == nil {
username := ""
password := ""
if registryConf.Auth != nil {
if registryConf.Auth.Username != nil {
username = *registryConf.Auth.Username
}
log.Done("Authentication successful (" + *registryConf.URL + ")")
buildOptions := &types.ImageBuildOptions{}
if registryConf.Auth.Password != nil {
password = *registryConf.Auth.Password
if imageConf.Build.Options != nil {
if imageConf.Build.Options.BuildArgs != nil {
buildOptions.BuildArgs = *imageConf.Build.Options.BuildArgs
}
}
log.StartWait("Authenticating (" + *registryConf.URL + ")")
buildErr = dockerBuilder.Authenticate(username, password, len(username) == 0)
log.StopWait()
buildErr = imageBuilder.BuildImage(contextPath, dockerfilePath, buildOptions)
if buildErr == nil {
log.Done("Authentication successful (" + *registryConf.URL + ")")
buildOptions := &types.ImageBuildOptions{}
if imageConf.Build.Engine.Docker.Options != nil {
if imageConf.Build.Engine.Docker.Options.BuildArgs != nil {
buildOptions.BuildArgs = *imageConf.Build.Engine.Docker.Options.BuildArgs
}
}
buildErr = dockerBuilder.BuildImage(contextPath, dockerfilePath, buildOptions)
buildErr = imageBuilder.PushImage()
if buildErr == nil {
buildErr = dockerBuilder.PushImage()
if buildErr == nil {
log.Info("Image pushed to registry (" + *registryConf.URL + ")")
}
log.Info("Image pushed to registry (" + *registryConf.URL + ")")
}
}
}
@@ -394,6 +415,10 @@ func (cmd *UpCmd) deployChart() {
chartPath := "chart/"
values := map[interface{}]interface{}{}
overwriteValues := map[interface{}]interface{}{}
yamlutil.ReadYamlFromFile(chartPath, values)
containerValues := map[string]interface{}{}
for imageName, imageConf := range *config.Images {
@@ -406,9 +431,25 @@ func (cmd *UpCmd) deployChart() {
}
containerValues[imageName] = container
}
values["containers"] = containerValues
appRelease, err := cmd.helm.InstallChartByPath(releaseName, releaseNamespace, chartPath, &values)
pullSecrets := []string{}
existingPullSecrets, pullSecretsExisting := values["pullSecrets"]
if pullSecretsExisting {
pullSecrets = existingPullSecrets.([]string)
}
for _, registryConf := range *config.Registries {
if registryConf.URL != nil {
registrySecretName := registry.GetRegistryAuthSecretName(*registryConf.URL)
pullSecrets = append(pullSecrets, registrySecretName)
}
}
overwriteValues["containers"] = containerValues
overwriteValues["pullSecrets"] = pullSecrets
appRelease, err := cmd.helm.InstallChartByPath(releaseName, releaseNamespace, chartPath, &overwriteValues)
log.StopWait()
@@ -144,7 +144,7 @@ func (b *Builder) BuildImage(contextPath, dockerfilePath string, options *types.
}
// Authenticate authenticates the client with a remote registry
func (b *Builder) Authenticate(user, password string, checkCredentialsStore bool) error {
func (b *Builder) Authenticate(user, password string, checkCredentialsStore bool) (*types.AuthConfig, error) {
ctx := context.Background()
authServer := getOfficialServer(ctx, b.client)
serverAddress := b.RegistryURL
@@ -154,12 +154,12 @@ func (b *Builder) Authenticate(user, password string, checkCredentialsStore bool
} else {
ref, err := reference.ParseNormalizedNamed(b.imageURL)
if err != nil {
return err
return nil, err
}
repoInfo, err := registry.ParseRepositoryInfo(ref)
if err != nil {
return err
return nil, err
}
if repoInfo.Index.Official {
@@ -176,7 +176,7 @@ func (b *Builder) Authenticate(user, password string, checkCredentialsStore bool
response, err := b.client.RegistryLogin(ctx, *authConfig)
if err != nil {
return err
return nil, err
}
if response.IdentityToken != "" {
@@ -185,7 +185,8 @@ func (b *Builder) Authenticate(user, password string, checkCredentialsStore bool
}
b.authConfig = authConfig
return nil
return b.authConfig, nil
}
// PushImage pushes an image to the specified registry
@@ -0,0 +1,9 @@
package builder
import "github.com/docker/docker/api/types"
type BuilderInterface interface {
Authenticate(username, password string, checkCredentialsStore bool) (*types.AuthConfig, error)
BuildImage(contextPath, dockerfilePath string, options *types.ImageBuildOptions) error
PushImage() error
}
Oops, something went wrong.

0 comments on commit 8e2ad15

Please sign in to comment.