diff --git a/internal/controller/validation/common.go b/internal/controller/validation/common.go index 5eaca139a..1d497ff8a 100644 --- a/internal/controller/validation/common.go +++ b/internal/controller/validation/common.go @@ -1,16 +1,21 @@ -// Copyright 2024 Apache Software Foundation (ASF) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package validation diff --git a/internal/controller/validation/common_test.go b/internal/controller/validation/common_test.go index f24d25ef6..57fac8421 100644 --- a/internal/controller/validation/common_test.go +++ b/internal/controller/validation/common_test.go @@ -1,16 +1,21 @@ -// Copyright 2024 Apache Software Foundation (ASF) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package validation @@ -98,8 +103,8 @@ func TestImageStoredInKindRegistry(t *testing.T) { } for _, test := range tests { - kindRegistryName = func(ctx context.Context) (string, error) { - return "172.18.0.4:5000", nil + kindRegistryName = func(ctx context.Context) string { + return "172.18.0.4:5000" } resolve = func(host string) ([]net.IP, error) { return []net.IP{net.ParseIP(test.resolvedIp)}, nil diff --git a/internal/controller/validation/image_validator.go b/internal/controller/validation/image_validator.go index c23bb9415..0664078ab 100644 --- a/internal/controller/validation/image_validator.go +++ b/internal/controller/validation/image_validator.go @@ -1,16 +1,21 @@ -// Copyright 2024 Apache Software Foundation (ASF) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package validation @@ -46,7 +51,7 @@ func (v *imageValidator) Validate(ctx context.Context, client client.Client, son return err } if !equals { - return fmt.Errorf("Workflow, defined in the image %s doesn't match deployment workflow", sonataflow.Spec.PodTemplate.Container.Image) + return fmt.Errorf("Workflow, defined in the image %s doesn't match deployment workflow %s", sonataflow.Spec.PodTemplate.Container.Image, sonataflow.Name) } return nil } @@ -72,7 +77,7 @@ func validateImage(ctx context.Context, sonataflow *operatorapi.SonataFlow) (boo return false, err } - reader, err := readWorkflowSpecLayer(ref) + reader, err := readWorkflowSpecLayer(ref, sonataflow) if err != nil { return false, err } @@ -118,7 +123,7 @@ func kindRegistryImage(sonataflow *operatorapi.SonataFlow) (v1.Image, error) { return ref, nil } -func readWorkflowSpecLayer(image v1.Image) (*tar.Reader, error) { +func readWorkflowSpecLayer(image v1.Image, sonataflow *operatorapi.SonataFlow) (*tar.Reader, error) { layers, err := image.Layers() if err != nil { return nil, err @@ -131,7 +136,7 @@ func readWorkflowSpecLayer(image v1.Image) (*tar.Reader, error) { return nil, err } } - return nil, fmt.Errorf("Workflow definition was not found in the Docker image") + return nil, fmt.Errorf("Workflow %s definition was not found in the Docker image", sonataflow.Name) } func findWorkflowSpecLayer(layer v1.Layer) (*tar.Reader, error) { diff --git a/internal/controller/validation/validator.go b/internal/controller/validation/validator.go index bbcfe1fc7..cb5724b15 100644 --- a/internal/controller/validation/validator.go +++ b/internal/controller/validation/validator.go @@ -1,16 +1,21 @@ -// Copyright 2024 Apache Software Foundation (ASF) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package validation @@ -28,7 +33,7 @@ type Validator interface { Validate(ctx context.Context, client client.Client, sonataflow *operatorapi.SonataFlow, req ctrl.Request) error } -// validate the SonataFlow object, right now it's only check if workflow is in deployment has image declared as that image +// Validate the SonataFlow object, right now it's only check if workflow is in deployment has image declared as that image // is the same as the image in the SonataFlow object func Validate(ctx context.Context, client client.Client, sonataflow *operatorapi.SonataFlow, req ctrl.Request) error { if sonataflow.HasContainerSpecImage() {