(cmd *cobra.Command, args []string)
| 81 | } |
| 82 | |
| 83 | func (command *kitCreateCommandOptions) run(cmd *cobra.Command, args []string) error { |
| 84 | c, err := command.GetCmdClient() |
| 85 | if err != nil { |
| 86 | return err |
| 87 | } |
| 88 | catalog := trait.NewCatalog(c) |
| 89 | kit := v1.NewIntegrationKit(command.Namespace, args[0]) |
| 90 | key := ctrl.ObjectKey{ |
| 91 | Namespace: command.Namespace, |
| 92 | Name: args[0], |
| 93 | } |
| 94 | if err := c.Get(command.Context, key, kit); err == nil { |
| 95 | // the integration kit already exists, let's check that it is |
| 96 | // not a platform one which is supposed to be "read only" |
| 97 | |
| 98 | if kit.Labels[v1.IntegrationKitTypeLabel] == v1.IntegrationKitTypePlatform { |
| 99 | fmt.Fprintln(cmd.OutOrStdout(), `integration kit "`+kit.Name+`" is not editable`) |
| 100 | |
| 101 | return nil |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | kit = v1.NewIntegrationKit(command.Namespace, kubernetes.SanitizeName(args[0])) |
| 106 | |
| 107 | if command.OperatorID != "" { |
| 108 | // --operator-id={id} is a syntax sugar for '--annotation camel.apache.org/operator.id={id}' |
| 109 | kit.SetOperatorID(strings.TrimSpace(command.OperatorID)) |
| 110 | } |
| 111 | |
| 112 | kit.Labels = map[string]string{ |
| 113 | v1.IntegrationKitTypeLabel: v1.IntegrationKitTypeUser, |
| 114 | } |
| 115 | kit.Spec = v1.IntegrationKitSpec{ |
| 116 | Dependencies: make([]string, 0, len(command.Dependencies)), |
| 117 | Configuration: make([]v1.ConfigurationSpec, 0), |
| 118 | Repositories: command.Repositories, |
| 119 | } |
| 120 | |
| 121 | if command.Image != "" { |
| 122 | // if the Image is set, the kit do not require any build but |
| 123 | // is be marked as external as the information about the classpath |
| 124 | // is missing so it cannot be used as base for other Kits |
| 125 | kit.Labels[v1.IntegrationKitTypeLabel] = v1.IntegrationKitTypeExternal |
| 126 | |
| 127 | // Set the Image to be used by the kit |
| 128 | kit.Spec.Image = command.Image |
| 129 | } |
| 130 | for _, item := range command.Dependencies { |
| 131 | switch { |
| 132 | case strings.HasPrefix(item, "camel-quarkus-"): |
| 133 | kit.Spec.Dependencies = append(kit.Spec.Dependencies, "camel:"+strings.TrimPrefix(item, "camel-quarkus-")) |
| 134 | case strings.HasPrefix(item, "camel-k-"): |
| 135 | kit.Spec.Dependencies = append(kit.Spec.Dependencies, "camel-k:"+strings.TrimPrefix(item, "camel-k-")) |
| 136 | case strings.HasPrefix(item, "camel-"): |
| 137 | kit.Spec.Dependencies = append(kit.Spec.Dependencies, "camel:"+strings.TrimPrefix(item, "camel-")) |
| 138 | default: |
| 139 | kit.Spec.Dependencies = append(kit.Spec.Dependencies, item) |
| 140 | } |
nothing calls this directly
no test coverage detected