This is an automated email from the ASF dual-hosted git repository.

jpoth pushed a commit to branch release-1.9.x
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit d9f6ed8f04363c0657fa9d8f612adbbf051cf623
Author: John Poth <poth.j...@gmail.com>
AuthorDate: Wed May 18 12:25:21 2022 +0200

    Fix: use platform.Status instead of platform.Spec
    
    (cherry picked from commit 17eb25a86a1d2c9e6d059a6f22da0dca3207a3cc)
---
 pkg/cmd/run.go        | 18 ++++++++++--------
 pkg/trait/registry.go |  8 ++++----
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/pkg/cmd/run.go b/pkg/cmd/run.go
index 147597d16..2607be584 100644
--- a/pkg/cmd/run.go
+++ b/pkg/cmd/run.go
@@ -597,13 +597,15 @@ func (o *runCmdOptions) createOrUpdateIntegration(cmd 
*cobra.Command, c client.C
                                if err != nil {
                                        return nil, err
                                }
-                               if platform.Spec.Build.Registry.CA != "" {
-                                       o.PrintfVerboseOutf(cmd, "We've noticed 
the image registry is configured with a custom certificate [%s] \n", 
platform.Spec.Build.Registry.CA)
+                               ca := platform.Status.Build.Registry.CA
+                               if ca != "" {
+                                       o.PrintfVerboseOutf(cmd, "We've noticed 
the image registry is configured with a custom certificate [%s] \n", ca)
                                        o.PrintVerboseOut(cmd, "Please make 
sure Kamel CLI is configured to use it or the operation will fail.")
                                        o.PrintVerboseOut(cmd, "More 
information can be found here 
https://nodejs.org/api/cli.html#cli_node_extra_ca_certs_file";)
                                }
-                               if platform.Spec.Build.Registry.Secret != "" {
-                                       o.PrintfVerboseOutf(cmd, "We've noticed 
the image registry is configured with a Secret [%s] \n", 
platform.Spec.Build.Registry.Secret)
+                               secret := platform.Status.Build.Registry.Secret
+                               if secret != "" {
+                                       o.PrintfVerboseOutf(cmd, "We've noticed 
the image registry is configured with a Secret [%s] \n", secret)
                                        o.PrintVerboseOut(cmd, "Please 
configure Docker authentication correctly or the operation will fail (by 
default it's $HOME/.docker/config.json).")
                                        o.PrintVerboseOut(cmd, "More 
information can be found here 
https://docs.docker.com/engine/reference/commandline/login/";)
                                }
@@ -964,7 +966,7 @@ func (o *runCmdOptions) extractGav(src *zip.File, localPath 
string, cmd *cobra.C
 
 func (o *runCmdOptions) uploadAsMavenArtifact(dependency maven.Dependency, 
path string, platform *v1.IntegrationPlatform, ns string, options 
spectrum.Options, cmd *cobra.Command) error {
        artifactHTTPPath := getArtifactHTTPPath(dependency, platform, ns)
-       options.Target = fmt.Sprintf("%s/%s:%s", 
platform.Spec.Build.Registry.Address, artifactHTTPPath, dependency.Version)
+       options.Target = fmt.Sprintf("%s/%s:%s", 
platform.Status.Build.Registry.Address, artifactHTTPPath, dependency.Version)
        if runtimeos.GOOS == "windows" {
                // workaround for 
https://github.com/container-tools/spectrum/issues/8
                // work with relative paths instead
@@ -1055,7 +1057,7 @@ func uploadChecksumFile(hash hash.Hash, tmpDir string, 
ext string, path string,
        if err = writeChecksumToFile(filepath, hash); err != nil {
                return err
        }
-       options.Target = fmt.Sprintf("%s/%s%s:%s", 
platform.Spec.Build.Registry.Address, artifactHTTPPath, ext, dependency.Version)
+       options.Target = fmt.Sprintf("%s/%s%s:%s", 
platform.Status.Build.Registry.Address, artifactHTTPPath, ext, 
dependency.Version)
        _, err = spectrum.Build(options, fmt.Sprintf("%s:.", filepath))
        return err
 }
@@ -1072,7 +1074,7 @@ func writeChecksumToFile(filepath string, hash hash.Hash) 
error {
 }
 
 func (o *runCmdOptions) getSpectrumOptions(platform *v1.IntegrationPlatform, 
cmd *cobra.Command) spectrum.Options {
-       insecure := platform.Spec.Build.Registry.Insecure
+       insecure := platform.Status.Build.Registry.Insecure
        var stdout io.Writer
        if o.Verbose {
                stdout = cmd.OutOrStdout()
@@ -1097,7 +1099,7 @@ func getArtifactHTTPPath(dependency maven.Dependency, 
platform *v1.IntegrationPl
        // Some vendors don't allow '/' or '.' in repository name so let's 
replace them with '_'
        artifactHTTPPath = strings.ReplaceAll(artifactHTTPPath, "/", "_")
        artifactHTTPPath = strings.ReplaceAll(artifactHTTPPath, ".", "_")
-       organization := platform.Spec.Build.Registry.Organization
+       organization := platform.Status.Build.Registry.Organization
        if organization == "" {
                organization = ns
        }
diff --git a/pkg/trait/registry.go b/pkg/trait/registry.go
index b1f47741e..acf6b377a 100644
--- a/pkg/trait/registry.go
+++ b/pkg/trait/registry.go
@@ -64,7 +64,7 @@ func (t *registryTrait) Configure(e *Environment) (bool, 
error) {
 }
 
 func (t *registryTrait) Apply(e *Environment) error {
-       registryAddress := e.Platform.Spec.Build.Registry.Address
+       registryAddress := e.Platform.Status.Build.Registry.Address
        if registryAddress == "" && e.Platform.Status.Cluster == 
v1.IntegrationPlatformClusterOpenShift {
                registryAddress = 
"image-registry.openshift-image-registry.svc:5000"
        }
@@ -72,8 +72,8 @@ func (t *registryTrait) Apply(e *Environment) error {
                return errors.New("could not figure out Image Registry URL, 
please set it manually")
        }
        build := getBuilderTask(e.BuildTasks)
-       registryCa := e.Platform.Spec.Build.Registry.CA
-       registrySecret := e.Platform.Spec.Build.Registry.Secret
+       registryCa := e.Platform.Status.Build.Registry.CA
+       registrySecret := e.Platform.Status.Build.Registry.Secret
        if e.Platform.Status.Cluster == v1.IntegrationPlatformClusterOpenShift {
                if registryCa == "" {
                        ca, err := getOpenShiftImageRegistryCA(e)
@@ -108,7 +108,7 @@ func (t *registryTrait) Apply(e *Environment) error {
 }
 
 func addRegistryAndExtensionToMaven(registryAddress string, build 
*v1.BuilderTask, platform *v1.IntegrationPlatform) {
-       organization := platform.Spec.Build.Registry.Organization
+       organization := platform.Status.Build.Registry.Organization
        if organization == "" {
                organization = platform.Namespace
        }

Reply via email to