Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c12f131
update: add build image to install codesphere, refactor installer, ad…
siherrmann Oct 28, 2025
b5d5fba
Merge branch 'main' into reference-base-image
siherrmann Oct 28, 2025
9009a5b
chore(docs): Auto-update docs and licenses
siherrmann Oct 28, 2025
0120619
fix: fix issues after main merge, small updates
siherrmann Oct 28, 2025
e74c5db
Merge branch 'reference-base-image' of https://github.com/codesphere-…
siherrmann Oct 28, 2025
889dc3a
chore(docs): Auto-update docs and licenses
siherrmann Oct 28, 2025
b2ecd0a
refac: refactor image file to not repeat docker podman if else
siherrmann Oct 30, 2025
cfbb6e9
update: clean up filewriter, add write function, add dockerfile updat…
siherrmann Oct 30, 2025
b0cacee
fix: fix lima-config, go did not install
siherrmann Oct 30, 2025
03cf176
feat: add build image command, add update dockerfile command, unify p…
siherrmann Oct 30, 2025
2169a41
Merge branch 'reference-base-image' of https://github.com/codesphere-…
siherrmann Oct 30, 2025
12b9f1e
update: update build image command description
siherrmann Oct 30, 2025
b8c09a0
update: update build image error on missing registry
siherrmann Oct 30, 2025
98fac5a
update: update docker from update to regexp, add tests
siherrmann Oct 31, 2025
3a7a00a
update: update global options to pointer
siherrmann Oct 31, 2025
3ec9e76
update: update dockerfile from update to only workspace agent images
siherrmann Oct 31, 2025
b12bde2
Merge branch 'main' into reference-base-image
siherrmann Oct 31, 2025
5d2a8ad
update: go mod tidy
siherrmann Oct 31, 2025
e6a4e25
update: regenerate docs
siherrmann Oct 31, 2025
12b8cac
chore(docs): Auto-update docs and licenses
siherrmann Oct 31, 2025
27bfd83
update: update image name handling
siherrmann Nov 3, 2025
460732f
update: remove required from description of non required flag
siherrmann Nov 3, 2025
8616407
Merge branch 'reference-base-image' of https://github.com/codesphere-…
siherrmann Nov 3, 2025
71f560f
Merge branch 'main' into reference-base-image
siherrmann Nov 3, 2025
30329b1
chore(docs): Auto-update docs and licenses
siherrmann Nov 3, 2025
425e547
fix: fix lint issues unhandled errors
siherrmann Nov 3, 2025
467965c
Merge branch 'reference-base-image' of https://github.com/codesphere-…
siherrmann Nov 3, 2025
fb45e37
fix: fix lint error unhandled error
siherrmann Nov 3, 2025
e0e3837
update: small PR updates
siherrmann Nov 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .mockery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,18 @@ packages:
config:
all: true
interfaces:
github.com/codesphere-cloud/oms/internal/installer:
config:
all: true
interfaces:
github.com/codesphere-cloud/oms/internal/portal:
config:
all: true
interfaces:
github.com/codesphere-cloud/oms/internal/system:
config:
all: true
interfaces:
github.com/codesphere-cloud/oms/internal/util:
config:
all: true
Expand Down
30 changes: 18 additions & 12 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@ Version: v3.5.1
License: MIT
License URL: https://github.com/blang/semver/blob/v3.5.1/LICENSE

----------
Module: github.com/clipperhouse/stringish
Version: v0.1.1
License: MIT
License URL: https://github.com/clipperhouse/stringish/blob/v0.1.1/LICENSE

----------
Module: github.com/clipperhouse/uax29/v2
Version: v2.2.0
Version: v2.3.0
License: MIT
License URL: https://github.com/clipperhouse/uax29/blob/v2.2.0/LICENSE
License URL: https://github.com/clipperhouse/uax29/blob/v2.3.0/LICENSE

----------
Module: github.com/codesphere-cloud/cs-go/pkg/io
Expand Down Expand Up @@ -71,9 +77,9 @@ License URL: https://github.com/inconshreveable/go-update/blob/8152e7eb6ccf/inte

----------
Module: github.com/jedib0t/go-pretty/v6
Version: v6.6.8
Version: v6.6.9
License: MIT
License URL: https://github.com/jedib0t/go-pretty/blob/v6.6.8/LICENSE
License URL: https://github.com/jedib0t/go-pretty/blob/v6.6.9/LICENSE

----------
Module: github.com/mattn/go-runewidth
Expand Down Expand Up @@ -113,9 +119,9 @@ License URL: https://github.com/spf13/pflag/blob/v1.0.10/LICENSE

----------
Module: github.com/stretchr/objx
Version: v0.5.2
Version: v0.5.3
License: MIT
License URL: https://github.com/stretchr/objx/blob/v0.5.2/LICENSE
License URL: https://github.com/stretchr/objx/blob/v0.5.3/LICENSE

----------
Module: github.com/stretchr/testify
Expand All @@ -137,21 +143,21 @@ License URL: https://github.com/ulikunitz/xz/blob/v0.5.15/LICENSE

----------
Module: golang.org/x/crypto
Version: v0.42.0
Version: v0.43.0
License: BSD-3-Clause
License URL: https://cs.opensource.google/go/x/crypto/+/v0.42.0:LICENSE
License URL: https://cs.opensource.google/go/x/crypto/+/v0.43.0:LICENSE

----------
Module: golang.org/x/oauth2
Version: v0.30.0
Version: v0.32.0
License: BSD-3-Clause
License URL: https://cs.opensource.google/go/x/oauth2/+/v0.30.0:LICENSE
License URL: https://cs.opensource.google/go/x/oauth2/+/v0.32.0:LICENSE

----------
Module: golang.org/x/text
Version: v0.29.0
Version: v0.30.0
License: BSD-3-Clause
License URL: https://cs.opensource.google/go/x/text/+/v0.29.0:LICENSE
License URL: https://cs.opensource.google/go/x/text/+/v0.30.0:LICENSE

----------
Module: gopkg.in/yaml.v3
Expand Down
26 changes: 26 additions & 0 deletions cli/cmd/build.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) Codesphere Inc.
// SPDX-License-Identifier: Apache-2.0

package cmd

import (
"github.com/codesphere-cloud/cs-go/pkg/io"
"github.com/spf13/cobra"
)

// BuildCmd represents the build command
type BuildCmd struct {
cmd *cobra.Command
}

func AddBuildCmd(rootCmd *cobra.Command, opts *GlobalOptions) {
build := BuildCmd{
cmd: &cobra.Command{
Use: "build",
Short: "Build and push images to a registry",
Long: io.Long(`Build and push container images to a registry using the provided configuration.`),
},
}
rootCmd.AddCommand(build.cmd)
AddBuildImagesCmd(build.cmd, opts)
}
105 changes: 105 additions & 0 deletions cli/cmd/build_images.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// Copyright (c) Codesphere Inc.
// SPDX-License-Identifier: Apache-2.0

package cmd

import (
"context"
"fmt"
"log"

"github.com/codesphere-cloud/cs-go/pkg/io"
"github.com/codesphere-cloud/oms/internal/env"
"github.com/codesphere-cloud/oms/internal/installer"
"github.com/codesphere-cloud/oms/internal/system"
"github.com/codesphere-cloud/oms/internal/util"
"github.com/codesphere-cloud/oms/internal/version"
"github.com/spf13/cobra"
)

// BuildImagesCmd represents the build images command
type BuildImagesCmd struct {
cmd *cobra.Command
Opts *BuildImagesOpts
Env env.Env
}

type BuildImagesOpts struct {
*GlobalOptions
Config string
}

func (c *BuildImagesCmd) RunE(_ *cobra.Command, args []string) error {
cm := installer.NewConfig()
im := system.NewImage(context.Background())

err := c.BuildAndPushImages(cm, im)
if err != nil {
return fmt.Errorf("failed to build and push images: %w", err)
}

return nil
}

func AddBuildImagesCmd(build *cobra.Command, opts *GlobalOptions) {
buildImages := BuildImagesCmd{
cmd: &cobra.Command{
Use: "images",
Short: "Build and push container images",
Long: io.Long(`Build and push container images based on the configuration file.
Extracts necessary images configuration to get the bomRef and processes them.`),
},
Opts: &BuildImagesOpts{GlobalOptions: opts},
Env: env.NewEnv(),
}
buildImages.cmd.Flags().StringVarP(&buildImages.Opts.Config, "config", "c", "", "Path to the configuration YAML file")

util.MarkFlagRequired(buildImages.cmd, "config")

build.AddCommand(buildImages.cmd)

buildImages.cmd.RunE = buildImages.RunE
}

func (c *BuildImagesCmd) BuildAndPushImages(cm installer.ConfigManager, im system.ImageManager) error {
config, err := cm.ParseConfigYaml(c.Opts.Config)
if err != nil {
return fmt.Errorf("failed to parse config: %w", err)
}

if len(config.Codesphere.DeployConfig.Images) == 0 {
return fmt.Errorf("no images defined in the config")
}
if len(config.Registry.Server) == 0 {
return fmt.Errorf("registry server not defined in the config")
}

v := &version.Build{}
codesphereVersion := v.Version()

for imageName, imageConfig := range config.Codesphere.DeployConfig.Images {
for flavorName, flavorConfig := range imageConfig.Flavors {
log.Printf("Processing image '%s' with flavor '%s'", imageName, flavorName)
if flavorConfig.Image.Dockerfile == "" {
log.Printf("Skipping flavor '%s', no dockerfile defined", flavorName)
continue
}

targetImage := fmt.Sprintf("%s/%s-%s:%s", config.Registry.Server, imageName, flavorName, codesphereVersion)

err := im.BuildImage(flavorConfig.Image.Dockerfile, targetImage, ".")
if err != nil {
return fmt.Errorf("failed to build image %s: %w", targetImage, err)
}

err = im.PushImage(targetImage)
if err != nil {
return fmt.Errorf("failed to push image %s: %w", targetImage, err)
}

log.Printf("Successfully built and pushed image: %s", targetImage)
}
}

return nil
}
Loading