Skip to content

Commit

Permalink
(#175) Make holos render --cluster-name flag optional
Browse files Browse the repository at this point in the history
Problem:
Rendering the whole platform doesn't need a cluster name.

Solution:
Make the flag optional, do not set the cue tag if it's empty.

Result:
Holos renders the platform resource and proceeds to the point where we
need to implement the iteration over platform components, passing the
platform model to each one and rendering the component.
  • Loading branch information
jeffmccune committed May 17, 2024
1 parent fb22e55 commit e4e7cd8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 3 additions & 1 deletion internal/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ func (b *Builder) Instances(ctx context.Context) ([]*build.Instance, error) {
}

// Refer to https://github.com/cue-lang/cue/blob/v0.7.0/cmd/cue/cmd/common.go#L429
cfg.Tags = append(cfg.Tags, "cluster="+b.Cluster())
if b.Cluster() != "" {
cfg.Tags = append(cfg.Tags, "cluster="+b.Cluster())
}
log.DebugContext(ctx, fmt.Sprintf("cue: tags %v", cfg.Tags))

return load.Instances(args, &cfg), nil
Expand Down
6 changes: 1 addition & 5 deletions internal/cli/render/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ func New(cfg *holos.Config) *cobra.Command {
cmd.Flags().AddGoFlagSet(flagSet)

cmd.RunE = func(cmd *cobra.Command, args []string) error {
if cfg.ClusterName() == "" {
return errors.Wrap(fmt.Errorf("missing cluster name"))
}

ctx := cmd.Context()
ctx := cmd.Root().Context()
log := logger.FromContext(ctx).With("cluster", cfg.ClusterName())
build := builder.New(builder.Entrypoints(args), builder.Cluster(cfg.ClusterName()))

Expand Down

0 comments on commit e4e7cd8

Please sign in to comment.