sigs.k8s.io/external-dns@v0.14.1/docs/scripts/docs.go (about) 1 /* 2 Copyright 2017 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package main 18 19 import ( 20 "log" 21 "os" 22 "strings" 23 ) 24 25 func removeLinkPrefixInIndex() { 26 content, err := os.ReadFile("./docs/index.md") 27 if err != nil { 28 log.Fatalf("Could not read index.md file. Make sure to run copy_docs.sh script first. Original error: %s", err) 29 } 30 31 updatedContent := strings.ReplaceAll(string(content), "](./docs/", "](") 32 updatedContent = strings.ReplaceAll(updatedContent, "](docs/", "](") 33 updatedContent = strings.ReplaceAll(updatedContent, "docs/img/external-dns.png", "img/external-dns.png") 34 35 f, err := os.OpenFile("./docs/index.md", os.O_RDWR, 0o644) 36 if err != nil { 37 log.Fatalf("Could not open index.md file to update content. Original error: %s", err) 38 } 39 defer f.Close() 40 41 if _, err := f.WriteString(updatedContent); err != nil { 42 log.Fatalf("Failed writing links update to index.md. Original error: %s", err) 43 } 44 } 45 46 func main() { 47 removeLinkPrefixInIndex() 48 }