From d06d67be0be921e336271902875b2767bd78589d Mon Sep 17 00:00:00 2001 From: Ondra Machacek Date: Mon, 18 Nov 2024 15:23:18 +0100 Subject: [PATCH] Make SSH key non-required Signed-off-by: Ondra Machacek --- api/v1alpha1/agent/spec.gen.go | 42 ++++++++++++------------ api/v1alpha1/openapi.yaml | 2 -- api/v1alpha1/spec.gen.go | 58 +++++++++++++++++----------------- api/v1alpha1/types.gen.go | 6 ++-- data/ignition.template | 2 ++ internal/image/ova.go | 6 ++-- internal/store/model/source.go | 2 +- internal/store/source_test.go | 16 +++++++++- internal/store/store_test.go | 6 ++-- 9 files changed, 79 insertions(+), 61 deletions(-) diff --git a/api/v1alpha1/agent/spec.gen.go b/api/v1alpha1/agent/spec.gen.go index 4e6b3a6..e1f28f7 100644 --- a/api/v1alpha1/agent/spec.gen.go +++ b/api/v1alpha1/agent/spec.gen.go @@ -19,27 +19,27 @@ import ( // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ - "H4sIAAAAAAAC/9RYS1PjOBD+Ky7tHp04sHPKDdh5pGZhKSiYA5VDY3diDbbkldqkWMr/fUuSHTux4oQM", - "s1t7I1arH19//RCvLJZ5IQUK0mz6ynScYg72z7MlCroloFLfFQkQmo+FkgUq4mhFYoUJCuKQ3anMfKCX", - "AtmUaVJcLFkVMp54P2urduBoJhbSe/yMSnMpPGdVyBT+VXKFCZs+NCY2FIZbHlv/Wp3zsNEpH79jTMbe", - "R6Wk6keeo9awtJAkqGPFC7JeOfmgOQ73ONnIzauQzcRCQd9SAgSapHK/OGGu+0ILhXgBBcScXj6fd8Dh", - "gnCJykRCkiDbK2S/7MPWnvY1htt++ACtP4BS8GJ+p1LTtVyhMlRz0UCScAMnZNcbUe5yt6PdaNPXqC6y", - "UhOqDch2Xl/7IpBWUj0NIS0gRy8xG+RQlHnNP5GAMvxKuBF7LAmTDiTD2Fo7h+DnkuDC1QOZ/2KQ8Z1v", - "22+Ft5X34e2nrwNi2OWuL5SZeEZBUr30YeZN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fQpVdAJ7Omxlw", + "4H23sR1wOW+mWDdHQ3o2x57pul3YbhC0FIeokT+63hUftigqyA9GdFcV7VVC+9ePb0FjfVNhy9ImvDfm", + "dClo07AO5ZYE+7jTL5nK9nvXmDMeo9DYLsrstIA4xeB4PDGjx4wLlhIVehpFq9VqDPZ4LNUyqu/q6I/Z", + "+cXV7cXoeDwZp5RnFjJOBs12JQuuMxACVXB6PQtGAZjHaoAiKSS3Mb69E1kpElxwgYllYIECCs6m7Lfx", + "ZHxkcABKLewRFDx6PoqsKh298qSK2olUlNR/7LlRGjipQC4CStG5wqypmv8JmzI3SztvamtaQY5ub3/Y", + "1D37fU0bN9+Mr82on7qx3zKDVIlh/YDfYwGr5u4yajqTiR3UsRRUr7BQFBmPrfvRd+3e263qoZrp/9ug", + "qhyFdSFNfo2C48mkj+afX02GjidH245O3NGHuOne9dazdVN3AkpKpeJ/O8acHE1+vtHPUqAtdALTAx6Y", + "S/vcfGp46RrRfsRUWGQQbzJTFxjzBcckcLp6JL1x17o74B40bbQ3Ov83VPXsutV6tzWObuHuB3rgY0TD", + "+H+BfGeQBDcO3v+uyiYnP9/olaRPshTJWqXVtHWlliJklBoDS/SUlTsO4hTjp17xfHF39+10HRdqq3Pr", + "skb13JSam5cRq+bVPwEAAP//0i8j+akVAAA=", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/api/v1alpha1/openapi.yaml b/api/v1alpha1/openapi.yaml index 3bdf442..7227d2b 100644 --- a/api/v1alpha1/openapi.yaml +++ b/api/v1alpha1/openapi.yaml @@ -262,7 +262,6 @@ components: - statusInfo - createdAt - updatedAt - - sshKey SourceCreate: type: object @@ -273,7 +272,6 @@ components: type: string required: - name - - sshKey SourceList: type: array diff --git a/api/v1alpha1/spec.gen.go b/api/v1alpha1/spec.gen.go index da3ff46..64df7de 100644 --- a/api/v1alpha1/spec.gen.go +++ b/api/v1alpha1/spec.gen.go @@ -18,35 +18,35 @@ import ( // Base64 encoded, gzipped, json marshaled Swagger object var swagger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alB90lRDQ4bUMaD57wxYpLIMo3pYqk/uYv2H", + "2369Xn0xuKvp9SfF2sPjXqz66dqHoSXRayC4uUz8/CgWynTA6G9sDCooW0j6G9p1vWjLMxo6U/HymVGs", + "roKr7SZAusRVK4Knz6y7C1JvT+xDePLyITyDmF15dH8i2rQrXfhDxKujyl0Po5r1zbUpDTn6R8XbXVmT", + "P9Y32Hq/sN9tb6vfIkb+XWKbM0EDmgMvRKvpi1eIfdXh/4JaVunvL6/0k6J3qpSPayQaIfYUKzASM4Fx", + "H3OvEOJfvP3F21fmbU8NDkVevQd20jpBcgT8fDNmM5H5t8ctRm6T+0+sJqZJ7v+j+L9GcBUR0sCQRv9k", + "1aHnXkhw7+i7mloRGUsHnIf4F99fjO8B//trIDuRhFpCxq5Rz1GzemMr2wLuQ+6zLkXIKO1NMb/MohSj", + "h1Y+vfdnuyncLqkNUyqtU+eHcQb7FPSPCiFfTVf/DgAA//86R0Es/iIAAA==", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/api/v1alpha1/types.gen.go b/api/v1alpha1/types.gen.go index 4aca297..007e030 100644 --- a/api/v1alpha1/types.gen.go +++ b/api/v1alpha1/types.gen.go @@ -100,7 +100,7 @@ type Source struct { Id openapi_types.UUID `json:"id"` Inventory *Inventory `json:"inventory,omitempty"` Name string `json:"name"` - SshKey string `json:"sshKey"` + SshKey *string `json:"sshKey,omitempty"` Status SourceStatus `json:"status"` StatusInfo string `json:"statusInfo"` UpdatedAt time.Time `json:"updatedAt"` @@ -111,8 +111,8 @@ type SourceStatus string // SourceCreate defines model for SourceCreate. type SourceCreate struct { - Name string `json:"name"` - SshKey string `json:"sshKey"` + Name string `json:"name"` + SshKey *string `json:"sshKey,omitempty"` } // SourceList defines model for SourceList. diff --git a/data/ignition.template b/data/ignition.template index 4c87444..3cd7199 100644 --- a/data/ignition.template +++ b/data/ignition.template @@ -4,8 +4,10 @@ passwd: users: - name: core password_hash: "$y$j9T$hUUbW8zoB.Qcmpwm4/RuK1$FMtuDAxNLp3sEa2PnGiJdXr8uYbvUNPlVDXpcJim529" + {{if .SshKey}} ssh_authorized_keys: - {{.SshKey}} + {{end}} storage: links: diff --git a/internal/image/ova.go b/internal/image/ova.go index b9a06be..dec142e 100644 --- a/internal/image/ova.go +++ b/internal/image/ova.go @@ -24,7 +24,7 @@ const ResponseWriterKey Key = 0 type Ova struct { Id uuid.UUID Writer io.Writer - SshKey string + SshKey *string } // IgnitionData defines modifiable fields in ignition config @@ -124,10 +124,12 @@ func writeOvf(tw *tar.Writer) error { func (o *Ova) generateIgnition() (string, error) { ignData := IgnitionData{ SourceId: o.Id.String(), - SshKey: o.SshKey, PlannerService: util.GetEnv("CONFIG_SERVER", "http://127.0.0.1:7443"), MigrationPlannerAgentImage: util.GetEnv("MIGRATION_PLANNER_AGENT_IMAGE", "quay.io/kubev2v/migration-planner-agent"), } + if o.SshKey != nil { + ignData.SshKey = *o.SshKey + } if insecureRegistry := os.Getenv("INSECURE_REGISTRY"); insecureRegistry != "" { ignData.InsecureRegistry = insecureRegistry diff --git a/internal/store/model/source.go b/internal/store/model/source.go index 6c9ddc2..4cd41c2 100644 --- a/internal/store/model/source.go +++ b/internal/store/model/source.go @@ -18,7 +18,7 @@ type Source struct { Name string Status string StatusInfo string - SshKey string + SshKey *string Inventory *JSONField[api.Inventory] `gorm:"type:jsonb"` CredUrl *string Agents []Agent `gorm:"constraint:OnDelete:SET NULL;"` diff --git a/internal/store/source_test.go b/internal/store/source_test.go index eb61110..c9b1b77 100644 --- a/internal/store/source_test.go +++ b/internal/store/source_test.go @@ -93,9 +93,23 @@ var _ = Describe("source store", Ordered, func() { Context("create", func() { It("successfully creates one source", func() { + sshKey := "some key" source, err := s.Source().Create(context.TODO(), v1alpha1.SourceCreate{ Name: "name-1", - SshKey: "some key", + SshKey: &sshKey, + }) + Expect(err).To(BeNil()) + Expect(source).NotTo(BeNil()) + + var count int + tx := gormdb.Raw("SELECT COUNT(*) FROM sources;").Scan(&count) + Expect(tx.Error).To(BeNil()) + Expect(count).To(Equal(1)) + }) + + It("successfully creates one source without sshkey", func() { + source, err := s.Source().Create(context.TODO(), v1alpha1.SourceCreate{ + Name: "name-1", }) Expect(err).To(BeNil()) Expect(source).NotTo(BeNil()) diff --git a/internal/store/store_test.go b/internal/store/store_test.go index ec51456..7893e31 100644 --- a/internal/store/store_test.go +++ b/internal/store/store_test.go @@ -16,6 +16,7 @@ var _ = Describe("Store", Ordered, func() { var ( store st.Store gormDB *gorm.DB + sshKey string ) BeforeAll(func() { @@ -24,6 +25,7 @@ var _ = Describe("Store", Ordered, func() { db, err := st.InitDB(cfg, log) Expect(err).To(BeNil()) gormDB = db + sshKey = "ssh-key" store = st.NewStore(db, log.WithField("test", "store")) Expect(store).ToNot(BeNil()) @@ -38,7 +40,7 @@ var _ = Describe("Store", Ordered, func() { ctx, err := store.NewTransactionContext(context.TODO()) Expect(err).To(BeNil()) - source, err := store.Source().Create(ctx, api.SourceCreate{Name: "test", SshKey: "some key"}) + source, err := store.Source().Create(ctx, api.SourceCreate{Name: "test", SshKey: &sshKey}) Expect(source).ToNot(BeNil()) Expect(err).To(BeNil()) @@ -56,7 +58,7 @@ var _ = Describe("Store", Ordered, func() { ctx, err := store.NewTransactionContext(context.TODO()) Expect(err).To(BeNil()) - source, err := store.Source().Create(ctx, api.SourceCreate{Name: "test", SshKey: "some key"}) + source, err := store.Source().Create(ctx, api.SourceCreate{Name: "test", SshKey: &sshKey}) Expect(source).ToNot(BeNil()) Expect(err).To(BeNil())