Skip to content

Commit

Permalink
Minor bugfixes (#1775)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljguarino authored Jan 24, 2025
1 parent 38a69b5 commit 7100db0
Show file tree
Hide file tree
Showing 24 changed files with 243 additions and 7 deletions.
2 changes: 2 additions & 0 deletions assets/src/generated/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4822,6 +4822,7 @@ export type PrAutomationEdge = {

/** templates to apply in this pr */
export type PrAutomationTemplateAttributes = {
context?: InputMaybe<Scalars['Json']['input']>;
destination: Scalars['String']['input'];
/** whether the source template is sourced from an external git repo bound to this automation */
external: Scalars['Boolean']['input'];
Expand Down Expand Up @@ -4942,6 +4943,7 @@ export enum PrStatus {
/** the details of where to find and place a templated file */
export type PrTemplateSpec = {
__typename?: 'PrTemplateSpec';
context?: Maybe<Scalars['Map']['output']>;
destination: Scalars['String']['output'];
external: Scalars['Boolean']['output'];
source: Scalars['String']['output'];
Expand Down
19 changes: 19 additions & 0 deletions charts/controller/crds/deployments.plural.sh_globalservices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,25 @@ spec:
chart:
description: chart to use
type: string
git:
description: A reference to a git folder/ref
properties:
files:
description: Optional files to add to the manifests for
this service
items:
type: string
type: array
folder:
description: Folder ...
type: string
ref:
description: Ref ...
type: string
required:
- folder
- ref
type: object
ignoreHooks:
description: whether you want to completely ignore any helm
hooks when actualizing this service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,25 @@ spec:
chart:
description: chart to use
type: string
git:
description: A reference to a git folder/ref
properties:
files:
description: Optional files to add to the manifests for
this service
items:
type: string
type: array
folder:
description: Folder ...
type: string
ref:
description: Ref ...
type: string
required:
- folder
- ref
type: object
ignoreHooks:
description: whether you want to completely ignore any helm
hooks when actualizing this service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,12 @@ spec:
items:
description: PrAutomationTemplate ...
properties:
context:
description: Additional context overrides to apply to this
template, will be merged into the user-provided configuration
options
type: object
x-kubernetes-preserve-unknown-fields: true
destination:
description: The destination to write the file to
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,25 @@ spec:
chart:
description: chart to use
type: string
git:
description: A reference to a git folder/ref
properties:
files:
description: Optional files to add to the manifests for this
service
items:
type: string
type: array
folder:
description: Folder ...
type: string
ref:
description: Ref ...
type: string
required:
- folder
- ref
type: object
ignoreHooks:
description: whether you want to completely ignore any helm hooks
when actualizing this service
Expand Down
12 changes: 7 additions & 5 deletions go/client/models_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions go/controller/api/v1alpha1/prautomation_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

console "github.com/pluralsh/console/go/client"

"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/yaml"
)

func init() {
Expand Down Expand Up @@ -264,17 +267,29 @@ type PrAutomationTemplate struct {
// The source file to use for templating
// +kubebuilder:validation:Optional
Source string `json:"source"`

// Additional context overrides to apply to this template, will be merged into the user-provided configuration options
// +kubebuilder:validation:Optional
Context *runtime.RawExtension `json:"context,omitempty"`
}

func (in *PrAutomationTemplate) Attributes() *console.PrAutomationTemplateAttributes {
if in == nil {
return nil
}

var context *string
if in.Context != nil {
if out, err := yaml.Marshal(in.Context); err == nil {
context = lo.ToPtr(string(out))
}
}

return &console.PrAutomationTemplateAttributes{
Source: in.Source,
Destination: in.Destination,
External: in.External,
Context: context,
}
}

Expand Down
4 changes: 4 additions & 0 deletions go/controller/api/v1alpha1/servicedeployment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ type ServiceHelm struct {
// +kubebuilder:validation:Optional
Repository *NamespacedName `json:"repository,omitempty"`

// A reference to a git folder/ref
// +kubebuilder:validation:Optional
Git *GitRef `json:"git,omitempty"`

// whether you want to completely ignore any helm hooks when actualizing this service
// +kubebuilder:validation:Optional
IgnoreHooks *bool `json:"ignoreHooks,omitempty"`
Expand Down
14 changes: 13 additions & 1 deletion go/controller/api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,25 @@ spec:
chart:
description: chart to use
type: string
git:
description: A reference to a git folder/ref
properties:
files:
description: Optional files to add to the manifests for
this service
items:
type: string
type: array
folder:
description: Folder ...
type: string
ref:
description: Ref ...
type: string
required:
- folder
- ref
type: object
ignoreHooks:
description: whether you want to completely ignore any helm
hooks when actualizing this service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,25 @@ spec:
chart:
description: chart to use
type: string
git:
description: A reference to a git folder/ref
properties:
files:
description: Optional files to add to the manifests for
this service
items:
type: string
type: array
folder:
description: Folder ...
type: string
ref:
description: Ref ...
type: string
required:
- folder
- ref
type: object
ignoreHooks:
description: whether you want to completely ignore any helm
hooks when actualizing this service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,12 @@ spec:
items:
description: PrAutomationTemplate ...
properties:
context:
description: Additional context overrides to apply to this
template, will be merged into the user-provided configuration
options
type: object
x-kubernetes-preserve-unknown-fields: true
destination:
description: The destination to write the file to
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,25 @@ spec:
chart:
description: chart to use
type: string
git:
description: A reference to a git folder/ref
properties:
files:
description: Optional files to add to the manifests for this
service
items:
type: string
type: array
folder:
description: Folder ...
type: string
ref:
description: Ref ...
type: string
required:
- folder
- ref
type: object
ignoreHooks:
description: whether you want to completely ignore any helm hooks
when actualizing this service
Expand Down
3 changes: 3 additions & 0 deletions go/controller/docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,7 @@ GitRef ...
_Appears in:_
- [InfrastructureStackSpec](#infrastructurestackspec)
- [PrAutomationCreateConfiguration](#prautomationcreateconfiguration)
- [ServiceHelm](#servicehelm)
- [ServiceSpec](#servicespec)
- [ServiceTemplate](#servicetemplate)

Expand Down Expand Up @@ -2146,6 +2147,7 @@ _Appears in:_
| `destination` _string_ | The destination to write the file to | | Required: {} <br /> |
| `external` _boolean_ | Whether it is being sourced from an external git repository | | Required: {} <br /> |
| `source` _string_ | The source file to use for templating | | Optional: {} <br /> |
| `context` _[RawExtension](https://pkg.go.dev/k8s.io/apimachinery/pkg/runtime#RawExtension)_ | Additional context overrides to apply to this template, will be merged into the user-provided configuration options | | Optional: {} <br /> |


#### PrAutomationTrigger
Expand Down Expand Up @@ -2542,6 +2544,7 @@ _Appears in:_
| `chart` _string_ | chart to use | | Optional: {} <br /> |
| `version` _string_ | chart version to use | | Optional: {} <br /> |
| `repository` _[NamespacedName](#namespacedname)_ | pointer to the FluxCD helm repository to use | | Optional: {} <br /> |
| `git` _[GitRef](#gitref)_ | A reference to a git folder/ref | | Optional: {} <br /> |
| `ignoreHooks` _boolean_ | whether you want to completely ignore any helm hooks when actualizing this service | | Optional: {} <br /> |


Expand Down
1 change: 1 addition & 0 deletions go/controller/internal/controller/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ func genServiceTemplate(ctx context.Context, c runtimeclient.Client, namespace s
Version: srv.Helm.Version,
URL: srv.Helm.URL,
IgnoreHooks: srv.Helm.IgnoreHooks,
Git: srv.Helm.Git.Attributes(),
}
if srv.Helm.Repository != nil {
serviceTemplate.Helm.Repository = &console.NamespacedName{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ func (r *ServiceReconciler) genServiceAttributes(ctx context.Context, service *v
Chart: service.Spec.Helm.Chart,
URL: service.Spec.Helm.URL,
IgnoreHooks: service.Spec.Helm.IgnoreHooks,
Git: service.Spec.Helm.Git.Attributes(),
}
if service.Spec.Helm.Repository != nil {
attr.Helm.Repository = &console.NamespacedName{
Expand Down
1 change: 1 addition & 0 deletions lib/console/deployments/cron.ex
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ defmodule Console.Deployments.Cron do
|> Observer.ordered(asc: :id)
|> Repo.stream(method: :keyset)
|> Task.async_stream(&Console.Deployments.Observer.Discovery.runner/1, max_concurrency: 50)
|> Stream.run()
end

defp log({:ok, %{id: id}}, msg), do: "Successfully #{msg} for #{id}"
Expand Down
2 changes: 2 additions & 0 deletions lib/console/graphql/deployments/git.ex
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ defmodule Console.GraphQl.Deployments.Git do
input_object :pr_automation_template_attributes do
field :source, non_null(:string)
field :destination, non_null(:string)
field :context, :json
field :external, non_null(:boolean),
description: "whether the source template is sourced from an external git repo bound to this automation"
end
Expand Down Expand Up @@ -515,6 +516,7 @@ defmodule Console.GraphQl.Deployments.Git do
object :pr_template_spec do
field :source, non_null(:string)
field :destination, non_null(:string)
field :context, :map
field :external, non_null(:boolean)
end

Expand Down
3 changes: 2 additions & 1 deletion lib/console/schema/pr_automation.ex
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ defmodule Console.Schema.PrAutomation do
field :source, :string
field :destination, :string
field :external, :boolean
field :context, :map
end
end

Expand Down Expand Up @@ -161,7 +162,7 @@ defmodule Console.Schema.PrAutomation do

defp template_changeset(model, attrs) do
model
|> cast(attrs, ~w(source destination external)a)
|> cast(attrs, ~w(source destination external context)a)
|> validate_required(~w(source destination)a)
end

Expand Down
Loading

0 comments on commit 7100db0

Please sign in to comment.